home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / vir_real / papers / norskog.5d < prev    next >
Encoding:
Text File  |  1993-06-20  |  112.0 KB  |  3,820 lines

  1.  
  2.                                   - 1 -
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.                            5D Reference Manual
  16.  
  17.                                Revision 0.1
  18.                          Release date: 4/21/1991
  19.  
  20.  
  21.           Copyright (c) 1991 by Lance Norskog, Santa Clara, USA
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.        1.  _I_n_t_r_o_d_u_c_t_i_o_n
  32.  
  33.        5D is a portable implementation of "virtual reality".  It
  34.        implements a simple, extensible programming language for
  35.        real-time 3D graphics interaction, and forms the basis of a
  36.        cyberspace/hypermedia-oriented window system.
  37.  
  38.        1.1  _S_c_o_p_e__o_f__5_D
  39.  
  40.        5D only addresses the _h_a_r_d_w_a_r_e _c_o_n_t_r_o_l level of 5D.  It
  41.        provides a pleasant programming language for creating custom
  42.        user interfaces, and network protocols for user interaction.
  43.        This system is intended first as a platform for
  44.        experimentation in 5D user interface and network interaction
  45.        betwixt decks in larger persistent worlds.
  46.  
  47.        1.2  _P_o_s_s_i_b_l_e__a_p_p_l_i_c_a_t_i_o_n_s
  48.  
  49.        5D is a Cyberspace building block.  It communicates data in
  50.        the form of 5D programs.  The 5D language encoding is dense
  51.        enough to download simple worlds in several minutes over
  52.        commodity 9600 baud modems, or ISDN.  With the future
  53.        inclusion of a 2D text rendering model, 5D could support
  54.        hypertext applications at this bandwidth.  X.25's ability to
  55.        support several simultaneous connections to separate phone
  56.        numbers opens impressive groupware and cyberspace doors.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.                                   - 2 -
  69.  
  70.  
  71.  
  72.        The reference application for low-end decks is MazeWar.
  73.        Several players on an Ethernet, one to a deck, wander
  74.        through a maze shooting at each other.  The decks
  75.        continuously broadcast the position, eye direction, laser
  76.        direction, and trigger status of their users.
  77.  
  78.        Scientific Visualization uses multi-dimensional viewing
  79.        methods.  Ray-tracing systems often include "fog"
  80.        implemented as 3D stochastic white-out blurring.  A 5D
  81.        system could support sci-vis by implementing fog from a 3D
  82.        dataset, thus allowing a surgeon to _e_x_p_e_r_i_e_n_c_e a brain scan
  83.        instead of viewing it.  This will, of course, not run in
  84.        real-time on a PC.
  85.  
  86.        The Habitat system [ref ??] uses standard computer game
  87.        technology and telecommunications to implement Cyberspace
  88.        with a real-time quasi-3D interface.  Every evening 300-400
  89.        people sit at home with a Commodore 64 and a 300 baud modem
  90.        playing an elaborate and permanent computer game with up to
  91.        5 other subscribers in a room or "cell".  Habitat has 20,000
  92.        cells total, and 15,000 paying subscribers.  It should be
  93.        possible to implement a 5D version of the Habitat system at
  94.        baud rates of 9600 on up.
  95.  
  96.        1.3  _5_D__G_l_o_s_s_a_r_y
  97.  
  98.        world               A "world" is a visible 3D scene with
  99.                            which the user interacts.
  100.  
  101.        deck                A "deck" is the combination of visual,
  102.                            sound, and force-feedback hardware that
  103.                            implements a 5D environment for one or a
  104.                            few users.
  105.  
  106.        program             On a network, a "program" is the remote
  107.                            application which is responsible for a
  108.                            world.
  109.  
  110.        World Manager       A World Manager is a remote program
  111.                            responsible for the main operation of
  112.                            the deck.  A typical deck is set up to
  113.                            have more than one world available; the
  114.                            WM allows switching between the
  115.                            different worlds.
  116.  
  117.        TerraFormer         The TTTTeeeerrrrrrrraaaaFFFFoooorrrrmmmmeeeerrrr is a visual programming
  118.                            CASE system for 5D trees.  It is a 5D
  119.                            program which presents a tree as a 3D
  120.                            scene, using translucent structure
  121.                            blocks to display several levels of
  122.                            structure simultaneously.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.                                   - 3 -
  135.  
  136.  
  137.  
  138.        2.  _5_D__S_y_s_t_e_m__A_r_c_h_i_t_e_c_t_u_r_e
  139.  
  140.        5D runs on personal computers and professional workstations.
  141.        It presents an interactive real-time 3D environment for the
  142.        user to work with.  It may read in and present a "canned"
  143.        world description from a file, or download one over a
  144.        network connection.  The world description consists of
  145.        picture elements (polygons, spheres, etc.)  which are drawn
  146.        in 3D, and many other software constructs necessary to
  147.        implement a complete free-running program inside the deck.
  148.        Constructs include various 3D graphics mathematics
  149.        operations, sound generation control, force feedback
  150.        control, and network communications.
  151.  
  152.        5D is a real-time simulation system for 3D graphics scenes.
  153.        A collection of objects exists, and exhibit various
  154.        behaviors in response to external input.
  155.  
  156.        2.1  _L_a_n_g_u_a_g_e__D_e_s_i_g_n__P_h_i_l_o_s_o_p_h_y
  157.  
  158.        "_W_e _t_o_o_k _a _f_e_w _s_i_m_p_l_e _i_d_e_a_s _a_n_d _b_e_a_t _t_h_e_m _t_o _d_e_a_t_h."
  159.        - _D_e_n_n_i_s _R_i_t_c_h_i_e _n_e_v_e_r _s_a_i_d _t_h_i_s _a_b_o_u_t _d_e_s_i_g_n_i_n_g _U_N_I_X.
  160.  
  161.        A real-time software system must veer in one of two opposing
  162.        directions:
  163.  
  164.           +o it can allow the programmer complete control over the
  165.             computer, and provide a range of services to a program,
  166.             _o_r
  167.  
  168.           +o it can take over the low-level control of the computer
  169.             and provide a set of high-level constructs which the
  170.             programmer can arrange into a program.  The system then
  171.             implements real-time response by "doing the best it
  172.             can" based on the given constructs.
  173.  
  174.        5D chooses the latter method.  It is a simulation
  175.        description language.  It includes a rich set of very
  176.        abstract operators for describing 3D graphics scenes.  The
  177.        point is to get as close as possible to letting the
  178.        programmer say "_d_o _w_h_a_t _I _m_e_a_n".  A general principle is
  179.        that the more abstract the language, the more efficient the
  180.        compiled code IFF the language constructs are carefully
  181.        designed for compilability.  The more the compiler
  182.        understands what you're "really" doing, the better code it
  183.        can generate.
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.                                   - 4 -
  201.  
  202.  
  203.  
  204.        2.2  _C_o_n_t_r_o_l
  205.  
  206.        "_W_h_e_n _I _h_e_a_r _t_h_e _w_o_r_d _M_a_c _I _r_e_a_c_h _f_o_r _m_y _g_u_n."
  207.  
  208.        Since 5D is never saved in binary format, the user may alter
  209.        any aspect of a world at any time.  User interfaces are
  210.        generally designed by programmers, who are generally
  211.        terrible at it.  5D users are not forced to operate canned
  212.        software, but may change it at any time.  The user is in
  213.        control, not the programmer.
  214.  
  215.        The 5D software community is encouraged to develop libraries
  216.        of new software which can be disseminated as simple tools,
  217.        not complete enclosed worlds.  A kinematics toolkit, for
  218.        example, is badly needed for many applications.
  219.  
  220.        2.3  _C_l_e_a_n_l_i_n_e_s_s
  221.  
  222.        The language is defined by a small set of basic operators
  223.        and data types, which are then combined to create useful
  224.        programming constructs.  Parsimony is a virtue in language
  225.        design.  _I_f _s_o_m_e_t_h_i_n_g _c_a_n _b_e _i_m_p_l_e_m_e_n_t_e_d _a_s _a _c_o_m_b_i_n_a_t_i_o_n _o_f
  226.        _e_x_i_s_t_i_n_g _c_o_n_s_t_r_u_c_t_s, _i_t _w_i_l_l _n_o_t _b_e _d_e_f_i_n_e_d _a_s _a _s_e_p_a_r_a_t_e
  227.        _b_u_i_l_t-_i_n _c_o_n_s_t_r_u_c_t.
  228.  
  229.        The primary motivation for this is that a system feature,
  230.        once made available to the user community, is immortal.
  231.        Mature systems generally have a thick layer of "barnacles",
  232.        old features which don't slough off like dead skin.  These
  233.        systems are much larger and more complex than they need to
  234.        be because they must provide backwards compatibility for
  235.        these "mistakes of youth".
  236.  
  237.        The 5D design process is a continuing search for simpler and
  238.        more basic constructs.  The best analogy is to the physical
  239.        world:  quarks are combined into protons, neutrons, and
  240.        electrons, which are combined into many different molecules,
  241.        which are ultimately combined into visible objects such as
  242.        chairs.
  243.  
  244.        The X Window System, on the other hand, includes 1000
  245.        different predefined molecules which don't fit together very
  246.        well.  5D was designed with the X Window System as a shining
  247.        example of poor design.
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.                                   - 5 -
  267.  
  268.  
  269.  
  270.        3.  _L_a_n_g_u_a_g_e__C_o_n_c_e_p_t_s
  271.  
  272.        5D was motivated by the need for a very high-level
  273.        programming language for implementing Virtual Reality
  274.        software.  It is interpretable, compilable, malleable to
  275.        parallel and custom graphics hardware configurations, and
  276.        friendly (well, maybe) to non-programmers.
  277.  
  278.        3.1  _D_e_s_i_g_n__c_o_n_s_t_r_a_i_n_t_s
  279.  
  280.        5D has four major design constraints:
  281.  
  282.          1.  It is a programming language for designing worlds.
  283.  
  284.          2.  It is a protocol for interacting with an application.
  285.  
  286.          3.  It operates in real-time; i.e. the language constructs
  287.              operate in a _p_r_e_d_i_c_t_a_b_l_e amount of time.
  288.  
  289.          4.  It is portable to the wide variety of the hardware
  290.              platforms used in computer graphics.
  291.  
  292.        The search for clean, elegant solutions for the problems
  293.        caused by these constraints is the source of most of the
  294.        peculiar features of the language.
  295.  
  296.        3.2  _H_i_e_r_a_r_c_h_i_c_a_l__D_i_s_p_l_a_y__L_i_s_t_s
  297.  
  298.        5D was inspired by the _h_i_e_r_a_r_c_h_i_c_a_l _d_i_s_p_l_a_y _l_i_s_t.  In
  299.        standard 3D modeling systems, a 3D scene description is
  300.        traversed and rendered each time the scene or the viewpoint
  301.        changes.  Abstract physical models are described as to their
  302.        shape, color, shininess, etc. Separate copies or _i_n_s_t_a_n_c_e_s
  303.        of these objects are then placed in 3-space.
  304.  
  305.        3.3  _I_n_h_e_r_i_t_a_n_c_e
  306.  
  307.        The objects _i_n_h_e_r_i_t their physical properties from their
  308.        base descriptions, but an individual instance may change any
  309.        of those properties.  Arranging these object definitions and
  310.        instantiations into trees gives the benefits of data-hiding
  311.        and modular software construction.  An object definition may
  312.        include by reference other object descriptions, and may also
  313.        change properties inherited from those object descriptions.
  314.        Object instantiations grouped into a tree may inherit
  315.        properties from the _p_a_r_e_n_t_s of the tree.  This is a very
  316.        powerful technique for describing the graphics portion of a
  317.        3D application; other techniques for data structuring can be
  318.        layered atop it as interconnections between tree members.
  319.        In PHIGS and other 3D modeling systems, these objects define
  320.        a static scene, and consist solely of graphics primitives.
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.                                   - 6 -
  333.  
  334.  
  335.  
  336.        Virtual Reality also needs to describe dynamic changes in a
  337.        world.  Games need to describe the physics of object
  338.        collision, while molecular models must implement gradual
  339.        force field interactions.  Many other standard programming
  340.        facilities are needed also, such as communication protocols
  341.        and I/O device drivers.
  342.  
  343.        3.4  _D_a_t_a_f_l_o_w__P_r_o_g_r_a_m_m_i_n_g
  344.  
  345.        5D extends the display list to a full programming language
  346.        by using the paradigm of Dataflow Programming [ref ??].
  347.        Dataflow languages express a complete program as a lattice
  348.        of operations.  At the beginning of a computation, values
  349.        enter the lattice of operations.  These values may be static
  350.        constants, the current value of input devices, or the
  351.        results of a previous computation.  At the end of
  352.        computation, one or more values pop out of the "top" of the
  353.        lattice; these are the results of the computation.
  354.  
  355.        A 5D "world" is a lattice.  This lattice is not evaluated in
  356.        one computation.  Instead, individual sub-lattices direct
  357.        the system when to evaluate them.  Sub-lattices draw on the
  358.        screen, emit sound, send network messages, and operate
  359.        force-feedback devices as side effects of their execution.
  360.  
  361.        3.4.1  _D_a_t_a_f_l_o_w__L_a_t_t_i_c_e__O_r_g_a_n_i_z_a_t_i_o_n
  362.        Each node of the lattice has an operator, one or more
  363.        super-nodes, zero or more subnodes, and zero or more
  364.        properties.  For purposes of a simple language organization,
  365.        lattices are organized into expression trees wherever
  366.        possible.  The object definition system (see below) makes
  367.        this feasible.
  368.  
  369.        3.5  _F_e_e_d_b_a_c_k
  370.  
  371.        5D objects can be connected in cyclic graphs.  This does not
  372.        imply that the language can get into an endless loop!  The
  373.        tree members are evaluated according to their frequency
  374.        properties.  The value of a tree in a cyclic graph is
  375.        eventually fed back into the next evaluation of that tree.
  376.        Feedback is a natural method for implementing rhythmic
  377.        objects and dynamics simulations; these are generally
  378.        defined with differential equations in a feedback loop.
  379.  
  380.        3.6  _O_b_j_e_c_t__O_r_i_e_n_t_a_t_i_o_n
  381.  
  382.        5D is an object-oriented language.  The fundamental paradigm
  383.        is object-oriented dataflow programming: a lattice, or
  384.        directed acyclic graph, of arithmetic expressions feeds a
  385.        set of software operations with numerical information.
  386.        These operations may draw geometric objects, make sounds,
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.                                   - 7 -
  399.  
  400.  
  401.  
  402.        send messages over communications channels, or control
  403.        force-feedback devices.
  404.  
  405.        Since these I/O devices must be controlled in real-time, 5D
  406.        does not contain constructs which require an unpredictable
  407.        amount of time to execute.  Whether this or that construct
  408.        is "efficient" is irrelevant to real-time work;
  409.        predictability is the issue.  Thus, very high-level language
  410.        concepts like actors, object messaging, dynamic
  411.        instantiation, etc. are not used.  The contents of the
  412.        lattice is limited to operations of known execution time.
  413.        Otherwise, the frame rate of the system would randomly vary
  414.        from several frames per second to several seconds per frame.
  415.  
  416.        Objects are used as the organizing principle for defining
  417.        the possible componenents of the lattice, and their possible
  418.        interconnection.  There is a large built-in library of
  419.        _p_r_i_m_i_t_i_v_e _c_l_a_s_s_e_s.  Programs may also define their own
  420.        classes.  References to user-defined classes are _r_e_w_r_i_t_t_e_n
  421.        according to their class definitions until the lattice is
  422.        entirely in terms of the primitive classes.  The resulting
  423.        lattice is incrementally compiled and executed repetitively.
  424.  
  425.  
  426.        4.  _L_a_n_g_u_a_g_e__R_e_f_e_r_e_n_c_e
  427.  
  428.        5D uses an extremely simple language.  It is built on
  429.        several elements:  objects, classes, properties, templates,
  430.        trees, and IDs.  These language elements are used to
  431.        describe rich, complex user interaction environments in a
  432.        very dense format.
  433.  
  434.        4.1  _O_b_j_e_c_t_s__a_n_d__C_l_a_s_s_e_s
  435.  
  436.        An _o_b_j_e_c_t is an element of an interactive environment.  A
  437.        _c_l_a_s_s is a generic description of a type of object.  Classes
  438.        may be modified and combined to create new classes.  The
  439.        original classes are called _p_a_r_e_n_t- or _s_u_p_e_r_c_l_a_s_s_e_s.  A deck
  440.        starts off with many pre-defined _p_r_i_m_i_t_i_v_e _c_l_a_s_s_e_s.  A 5D
  441.        program may include new class definitions which derive from
  442.        the primitive ones.  A class may contain two or more objects
  443.        from different parent classes.  This means that a class is
  444.        always an extended or modified version of its parents.  It
  445.        may add and delete operators and properties, possibly
  446.        overriding definitions inherited from the parent classes.
  447.  
  448.        Objects are instances of their class definition.  Objects
  449.        may be leaf nodes, or may be _c_o_n_s_t_r_u_c_t_e_d from objects of
  450.        other classes.
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.                                   - 8 -
  465.  
  466.  
  467.  
  468.        4.1.1  _T_y_p_e_s
  469.        Some classes are types, some are not.  _A_b_s_t_r_a_c_t _s_u_p_e_r_c_l_a_s_s_e_s
  470.        are defined only so that child classes may be derived from
  471.        them.  They are not useful for instancing objects, and thus
  472.        do not allow this to occur.  Types are classes which may be
  473.        used for instancing objects.
  474.  
  475.        4.2  _T_e_m_p_l_a_t_e_s
  476.  
  477.        A _t_e_m_p_l_a_t_e describes a space of possible 5D program trees.
  478.        Templates are used several ways in 5D.  Most important,
  479.        templates are used to describe the space of possible uses of
  480.        an operator in a class definition.  This allows an operator
  481.        definition to handle several different invocations.
  482.        Templates are also used to verify a tree downloaded from a
  483.        network connection; they supply a "syntax check" for
  484.        accepted trees which can be used to decide whether to
  485.        execute a downloaded tree.
  486.  
  487.        4.2.1  _T_e_m_p_l_a_t_e__s_y_n_t_a_x__[__p_r_o_p_o_s_e_d__]
  488.        Template trees are separate type of tree node.  There are
  489.        several forms of template node, defined by the _k_i_n_d=
  490.        keyword.  Here are the values of the _k_i_n_d= keyword and the
  491.        associated sub-tree formats:
  492.  
  493.        multi (X)           maps to 0 or more occurrences of the
  494.                            tree node (X).
  495.  
  496.        order (X) (Y)       maps to the tree pair (X) (Y) or the
  497.                            tree pair (Y) (X).
  498.  
  499.        sub (X)             maps to an arbitrary-shaped tree of
  500.                            nodes described by (X).
  501.  
  502.        and (X) (Y)         maps to the boolean AND of the trees
  503.                            described by (X) and (Y).
  504.  
  505.        or (X) (Y)          maps to the boolean OR of the trees
  506.                            described by (X) and (Y).
  507.  
  508.        not (X)             maps to the boolean NOT of the tree
  509.                            described by (X).
  510.  
  511.        Notes:
  512.        The _o_r_d_e_r, _a_n_d, and _o_r nodes may contain two or more
  513.        children.
  514.  
  515.        Templates are, by nature, underspecified.  A template
  516.        without the _k_i_n_d keyword may use _t_y_p_e. A _t_y_p_e template may
  517.        optionally use _v_a_l_u_e.  This template describes 0 or more
  518.        Numbers:
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.                                   - 9 -
  531.  
  532.  
  533.  
  534.                 (template kind=multi
  535.                     (template type=Number))
  536.  
  537.        Tree templates may be used in combination. The template:
  538.                 (template kind=sub
  539.                     (template kind=or
  540.                         (template type=Void)
  541.                         (template type=Number)))
  542.  
  543.        corresponds to one or more trees of algebraic expressions.
  544.        Since the Number class does not operate on Voids, thus legal
  545.        5D trees matching this template can be a one or more Number
  546.        expressions hanging under a tree of Voids, or one Number
  547.        expression with no Voids at all.
  548.        Templates may be assigned IDs.
  549.  
  550.        A nodes of type Address may substitute at any place for any
  551.        other node, if its referent node matches a template.  Nodes
  552.        of type Address may also be specified in a template.
  553.        [ Templates have proven the thorniest design task in 5D.
  554.        I'm still not happy with the design. ]
  555.  
  556.        4.3  _P_r_o_p_e_r_t_i_e_s
  557.  
  558.        If objects are nouns, properties are adjectives.  Properties
  559.        influence the nature of objects.  Drawable objects, as
  560.        mentioned above, have colors and reflectivity.  Other
  561.        objects have other properties:  sound channels, for example,
  562.        have the property of volume.  The value of a property may be
  563.        specified by a separate 5D program tree. The one restriction
  564.        here is that no object used in the program tree may itself
  565.        have properties.
  566.  
  567.        However, a property itself has a few attributes:
  568.  
  569.        Inheritance         The properties of a node may be
  570.                            inherited automatically down the tree.
  571.                            Every node of type X may use or set the
  572.                            properties defined for class X.  An
  573.                            inheritable property which is set at a
  574.                            node overrides the inherited value of
  575.                            those properties.  The new setting is
  576.                            visible to all of its children of the
  577.                            same type.
  578.  
  579.        Default             Every property description includes a
  580.                            default value for a property.  If a
  581.                            value is not specified or inherited for
  582.                            that property, the default is used.
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.                                   - 10 -
  597.  
  598.  
  599.  
  600.        Writeability        A property may or may not be changed by
  601.                            a node.  A read-only property may be set
  602.                            at the top of a tree and then not reset
  603.                            by its children.
  604.  
  605.        4.4  _T_r_e_e_s_,__L_a_t_t_i_c_e_s_,__a_n_d__C_y_c_l_i_c__G_r_a_p_h_s
  606.  
  607.        First, some basic Graph Theory:  a _g_r_a_p_h is a collection of
  608.        nodes connected by edges.  A graph where the edges have a
  609.        direction assigned to them is a _d_i_r_e_c_t_e_d _g_r_a_p_h.  A _t_r_e_e is a
  610.        graph in which there are no loops at all.  A _l_a_t_t_i_c_e is a
  611.        directed graph in which there are no loops at all.  Unlike a
  612.        tree, a lattice may have two or more edges "pointing" at the
  613.        same node.  A _d_i_r_e_c_t_e_d _c_y_c_l_i_c _g_r_a_p_h may have loops where the
  614.        edges form a circle.
  615.  
  616.        In 5D a program is described by a directed graph which has
  617.        aspects of a tree, a lattice, and a directed cyclic graph.
  618.        A program is specified as a tree.  Each branch or leaf of
  619.        the tree is called a _n_o_d_e.  Special _p_o_i_n_t_e_r _n_o_d_e_s may refer
  620.        to other nodes, which may in fact be _p_a_r_e_n_t _n_o_d_e_s.  Thus,
  621.        with pointer nodes the tree can become a lattice or even a
  622.        cyclic graph.  [ Think of the UNIX file system with symbolic
  623.        links. ]
  624.  
  625.        4.4.1  _P_r_o_p_e_r_t_y__I_n_h_e_r_i_t_a_n_c_e__v_i_a__p_o_i_n_t_e_r_s
  626.        Properties are inherited statically, not dynamically.  When
  627.        trees are executed via pointers, they still inherit their
  628.        properties from their tree parent, not via pointing node.
  629.  
  630.        4.5  _I_D_s
  631.  
  632.        Any node in a 5D program tree may have a name attached to
  633.        it.  This name must be unique within a subset of the tree.
  634.        Names are assigned via the ID keyword.
  635.  
  636.        IDs is useful in several contexts.  Class definitions name
  637.        themselves this way.  Variables named with IDs are used to
  638.        transform the program tree into a lattice.  Certain IDs have
  639.        special pre-defined meanings.
  640.  
  641.        4.6  _T_r_e_e__c_o_n_s_t_r_u_c_t_i_o_n_
  642.  
  643.        Each node of the tree is one of a few node types.  One or
  644.        more keywords modify the node type.
  645.  
  646.        4.6.1  _N_o_d_e__t_y_p_e_s
  647.        5D has several types of tree nodes:
  648.  
  649.        Class               indicates that the entire tree is a
  650.                            class definition.  A class node must
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.                                   - 11 -
  663.  
  664.  
  665.  
  666.                            have the keywords IIIIDDDD and ssssuuuuppppeeeerrrr.
  667.  
  668.        Property            specifies a property of this node.  In a
  669.                            class definition, a property node
  670.                            defines a property which instances of
  671.                            this class have.  In an object
  672.                            instantiation, an property node sets a
  673.                            property of this node.  A property node
  674.                            must have the keywords IIIIDDDD and _t_y_p_e, and
  675.                            must have a subtree containing the
  676.                            default value of the property.
  677.  
  678.        Input               in a class definition specifies a
  679.                            collection of superclass objects which
  680.                            form this class.
  681.  
  682.        Data                in a class definition specifies a
  683.                            collection of superclass objects which
  684.                            are secret to an instantiation of this
  685.                            class.
  686.  
  687.        Op                  specifies an operation node.  In a class
  688.                            definition, an operation node and
  689.                            subtree indicate a method the class
  690.                            implements.  In an object instantiation,
  691.                            an operation node invokes the
  692.                            corresponding method in the class
  693.                            definition.  An op node may have the
  694.                            keywords IIIIDDDD and nnnnaaaammmmeeee.
  695.  
  696.        Template            specifies a variable-format tree.  A
  697.                            template tree defines a space of
  698.                            possible tree shapes.  It must have the
  699.                            ffffoooorrrrmmmmaaaatttt keyword.
  700.  
  701.        Rewrite             specifies the replacement tree in a
  702.                            method.
  703.  
  704.        Comment             is used for multi-line commentary.
  705.  
  706.        Set                 is the dataflow lattice connection
  707.                            operation.  Set assigns the value of the
  708.                            right-hand tree to the left-hand
  709.                            nodename.
  710.  
  711.        4.6.2  _M_o_d_i_f_i_e_r_s
  712.        5D has several basic modifiers:
  713.  
  714.        ID                  assigns a unique name to this node.  Any
  715.                            node may have a name attached to it.
  716.                            This name must be unique, subject to
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.                                   - 12 -
  729.  
  730.  
  731.  
  732.                            certain restrictions noted below in the
  733.                            section "Scoping Rules".
  734.  
  735.        Super               indicates a superclass.  This is used
  736.                            several ways in class definitions.  In
  737.                            the class definition node, it names the
  738.                            parent classes.  In the operator and
  739.                            property definition nodes, it may be
  740.                            used to refer to properties defined by
  741.                            parent classes.
  742.  
  743.        Type                indicates the class of a property or
  744.                            operation by naming the class definition
  745.                            node.
  746.  
  747.        Name                indicates the name of the operation in
  748.                            an operation node
  749.  
  750.        Value               indicates the actual value contained by
  751.                            a leaf node.  A value is a number in
  752.                            standard C decimal, octal, or hex
  753.                            format.
  754.  
  755.        Format              defines the type of a template node in a
  756.                            template subtree.
  757.  
  758.        Refer               means that this node is an indirect
  759.                            node.  The value of the Refer keyword is
  760.                            an ID.  This node receives its type and
  761.                            value from the ID'd node.  This node may
  762.                            also possess a Type keyword, which must
  763.                            match the type of the ID'd node.  [ TTTThhhhiiiissss
  764.                            iiiissss uuuuggggllllyyyy.... IIIItttt sssshhhhoooouuuulllldddd nnnnooootttt eeeexxxxiiiisssstttt....  CCCCllllaaaassssssss
  765.                            AAAAddddddddrrrreeeessssssss hhhhaaaannnnddddlllleeeessss tttthhhhiiiissss....  EEEEiiiitttthhhheeeerrrr tttthhhhaaaatttt,,,, oooorrrr
  766.                            ccccllllaaaassssssss AAAAddddddddrrrreeeessssssss sssshhhhoooouuuulllldddd nnnnooootttt eeeexxxxiiiisssstttt aaaannnndddd aaaallllllll
  767.                            ppppooooiiiinnnntttteeeerrrrssss sssshhhhoooouuuulllldddd bbbbeeee ddddoooonnnneeee wwwwiiiitttthhhh RRRReeeeffffeeeerrrr.... ]
  768.  
  769.        IsType              is a boolean expression for whether or
  770.                            not a class definition is a _t_y_p_e.  A
  771.                            class definition which is not a type may
  772.                            only be used as an abstract superclass,
  773.                            it may not be used in a program.
  774.  
  775.        Inherited           is a boolean expression for whether or
  776.                            not a property is inherited.  If it is
  777.                            not, it must be explicitly specified in
  778.                            each use of the object.
  779.  
  780.        Remove              deletes an inherited operator or
  781.                            property from a class definition.
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.                                   - 13 -
  795.  
  796.  
  797.  
  798.        writeable           is a Boolean value in property
  799.                            definitions.  If false, the property may
  800.                            not be changed by its heirs or by the
  801.                            "set properties" operator in the Void
  802.                            object.
  803.  
  804.        Along with keywords, there may be arbitrary text surrounded
  805.        by double quotes (").  These are comments and are ignored by
  806.        the 5D interpreter.
  807.  
  808.        4.6.2.1  _C_o_m_m_e_n_t__c_o_n_v_e_n_t_i_o_n_s
  809.        The 5D development system has several conventions for
  810.        comments.  A comment beginning with the string "Summary:" is
  811.        considered to be a short (one-line) summary of this tree
  812.        node, and should be used in class, operator, and property
  813.        definition nodes.  A comment beginning with the string
  814.        "Treetype:" is a directive to the TTTTeeeerrrrrrrraaaaFFFFoooorrrrmmmmeeeerrrr that a tree is
  815.        a specific type of database, such as a 3D model or a
  816.        differential equation, and should be displayed or edited
  817.        with a special application.
  818.  
  819.        4.7  _T_r_e_e__e_n_c_o_d_i_n_g
  820.  
  821.        There are two possible tree encodings, ascii & ASN.1 binary
  822.        format.
  823.  
  824.        4.7.1  _A_s_c_i_i__F_o_r_m_a_t
  825.        The 5D ASCII syntax is rudimentary, to say the least.  It is
  826.        designed to be very quick to parse, both by a deck and by
  827.        the TerraFormer.  It is in standard US 7-bit ASCII, with 8-
  828.        bit and 16-bit text allowed in comments.  You may send it in
  829.        e-mail, and control it with SCCS or RCS.  You're just not
  830.        expected to read it, and you are strongly urged not to write
  831.        it.
  832.  
  833.        A tree node is started by left parentheses (LP) and stopped
  834.        by right parentheses (RP).  After the LP comes one of the
  835.        above node type strings.  After the node type are zero or
  836.        more keywords.  Some of the keywords may be of the form
  837.        aaaaa=bbbbb.  These keywords are accepted by the node type
  838.        keyword according to its wont.  After these keywords comes,
  839.        you guessed it, another LP or an RP.  A series of RP's may
  840.        be expressed by a right bracket (RB).  An RB substitutes for
  841.        RP only if there can be nothing but the RP at that location.
  842.  
  843.        The exact syntax of the contents of data nodes is not final.
  844.        Numbers are stored in the standard C "printf" floating point
  845.        formats.  Images are stored in PBM format.  Sound samples
  846.        are stored as a series of text numbers, unsigned.  Ascii
  847.        text strings are not supported as data.  See section "Text".
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.                                   - 14 -
  861.  
  862.  
  863.  
  864.        4.7.2  _A_S_N_._1
  865.        A 5D program is encoded as one large tree.  The node
  866.        contains the type and whatever keywords are there as a data
  867.        structure of strings.
  868.  
  869.        Existing source code from an SNMP agent which encodes and
  870.        decodes a pre-defined ASN.1 grammar looks quite time-
  871.        efficient.  Binary data is stored in the ASN.1 format in
  872.        very compact formats.
  873.  
  874.        It may be necessary to process a received tree "on the fly"
  875.        without storing the entire tree in source form.  The ASN.1
  876.        format might work better in postfix format rather than the
  877.        ASCII format's prefix format, Simple tree nodes are
  878.        processed first, then knitted together.  The "incoming
  879.        stack" maintains the database of processed trees which await
  880.        the processing of their controlling nodes.
  881.  
  882.        4.7.3  _T_r_e_e__E_n_c_o_d_i_n_g__S_u_m_m_a_r_y
  883.        The ASCII format is readable, and may be mailed and used
  884.        under software control systems.  But, it is not very dense,
  885.        and in particular uses very inefficient methods for storing
  886.        binary data.  The ASCII format is used as a fluid medium for
  887.        experiments in rearranging the 5D syntax.
  888.  
  889.        The ASCII format will be the dominant use in development,
  890.        authoring, and workstation environments, but the broader
  891.        network-based users will use ASN.1 almost exclusively
  892.        because its an international standard and because of its
  893.        space-efficiency.
  894.  
  895.        4.8  _C_l_a_s_s__d_e_f_i_n_i_t_i_o_n
  896.  
  897.        A class definition has up to five sections:
  898.  
  899.        Superclass          The superclasses used to derive this
  900.                            class.
  901.  
  902.        Property            The properties used by the class.
  903.  
  904.        Data                Secret data objects used by a member of
  905.                            this class.
  906.  
  907.        Input               Some classes are ordered lists of parent
  908.                            objects.
  909.  
  910.        Method              The rewrite rules for the class.
  911.  
  912.        The Property, Data, and Input sections are optional.
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.                                   - 15 -
  927.  
  928.  
  929.  
  930.        4.8.1  _S_u_p_e_r_c_l_a_s_s__S_e_c_t_i_o_n
  931.        The superclass section defines all the parent classes of a
  932.        class.  The 5D class heirarchy is a lattice:  at the top is
  933.        the class Object which effectively does nothing.  It is the
  934.        only class with no superclass.  All other classes have one
  935.        or more superclasses.  The properties and operators defined
  936.        in the parent classes are automatically inherited by the
  937.        class.
  938.  
  939.        4.8.2  _P_r_o_p_e_r_t_y__S_e_c_t_i_o_n
  940.        The property section defines any properties which may affect
  941.        the operation of this class.  For example, class Drawable
  942.        contains 3D visible objects and thus has the properties of
  943.        color, reflectivity, etc.  But, class Number has no
  944.        properties:  "5 + 4" is always 9.
  945.  
  946.        4.8.3  _D_a_t_a__S_e_c_t_i_o_n
  947.        The Data section defines secret data objects.  These are
  948.        unique to each instantiation of a class, and may only be
  949.        manipulated within the class definition.
  950.  
  951.        4.8.4  _I_n_p_u_t__S_e_c_t_i_o_n
  952.        Classes which contain Input sections are "aggregations" or
  953.        collections of objects.  For example, a Point is 3 Numbers.
  954.        The Input section is optional.  Classes without Input
  955.        sections may redefine the behavior of a parent class, or
  956.        create a new class with behaviors of several parent classes.
  957.        Operations on the members of the Input section are inherited
  958.        _i_n _t_o_t_o:  see the definition of addition and subtraction on
  959.        Complex numbers below.
  960.  
  961.        4.8.5  _M_e_t_h_o_d__s_e_c_t_i_o_n_s
  962.        The Method sections give the substition rules for a class.
  963.        A "method" handles a given operation on an object.  For
  964.        example, class Number has a method `+' which handles adding
  965.        two or more numbers.  Tree templates are used to describe
  966.        possible invocations of an operator in the context of this
  967.        type.  A second tree of object operations is substituted for
  968.        the matched tree.  This second tree is called the _r_e_w_r_i_t_e
  969.        rule, because operator invocations are _r_e_w_r_i_t_t_e_n.
  970.  
  971.        The template facility is a powerful context-sensitive device
  972.        for describing the use of an object.  It describes the
  973.        replacement expression tree for each operation that can be
  974.        performed on the object.  For example, the operation
  975.        Vertex_Normal on a Point is substituted with the appropriate
  976.        mathematics on the constituent Numbers.
  977.  
  978.        When an object instance is evaluated, one of the methods in
  979.        the object's tuple list is evaluated and its outputs are the
  980.        outputs of the instance.  Which method? _T_h_e _o_n_e _w_h_o_s_e
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.                                   - 16 -
  993.  
  994.  
  995.  
  996.        _t_e_m_p_l_a_t_e _m_a_t_c_h_e_s _t_h_e _s_h_a_p_e _o_f _t_h_e _t_r_e_e _s_u_r_r_o_u_n_d_i_n_g _t_h_e
  997.        _e_v_a_l_u_a_t_i_o_n _o_f _t_h_e _i_n_s_t_a_n_c_e.  There may not be two templates
  998.        which both match the same tree.  [I think it is possible to
  999.        discover this with static analysis of the entire class
  1000.        definition lattice.]  [On second thought, this may be
  1001.        "halting problem" material, or at least NP-nasty.]
  1002.  
  1003.        4.8.6  _C_l_a_s_s__I_n_h_e_r_i_t_a_n_c_e
  1004.        Classes automatically inherit properties and methods from
  1005.        all superclasses.  Properties which have the same name are
  1006.        disambiguated by class name.  Operators with the same name
  1007.        must be redefined.  The parent operators may be invoked
  1008.        within the rewrite rule via the _s_u_p_e_r=ppppaaaarrrreeeennnntttt keyword.
  1009.  
  1010.        4.8.6.1  _C_l_a_s_s_:__C_o_m_p_l_e_x__N_u_m_b_e_r
  1011.        For example, an abridged object definition for complex
  1012.        numbers:
  1013.  
  1014.             ( class
  1015.                 ID=Complex
  1016.                 superclass=Number
  1017.                 ( input
  1018.                     (type=Number ID=re)
  1019.                     (type=Number ID=im)
  1020.                 )
  1021.                 / create a Complex number from two Numbers
  1022.                 ( op name=Complex type=Complex
  1023.                     ( template
  1024.                         (type=Number ID=input1)
  1025.                         (type=Number ID=input2)
  1026.                     )
  1027.                     ( rewrite
  1028.                         (set (output.re, input1))
  1029.                         (set (output.im, input2))
  1030.                     )
  1031.                 )
  1032.                 / decompose a Complex number into its constituent Numbers
  1033.                 ( op name=Real type=Number
  1034.                     ( template
  1035.                         ID=output
  1036.                         (type=Complex ID=input)
  1037.                     )
  1038.                     ( rewrite
  1039.                         (set (output, input1.re))
  1040.                     )
  1041.                 )
  1042.  
  1043.                                   - 17 -
  1044.  
  1045.  
  1046.  
  1047.                 ( op name=Imag type=Number
  1048.                     ( template
  1049.                         ID=output
  1050.                         (type=Complex ID=input)
  1051.                     )
  1052.                     ( rewrite
  1053.                         (set (output, input1.im))
  1054.                     )
  1055.                 )
  1056.                 / arithmetic operators
  1057.                 / C1 + C2 = C1.re + C2.re, C1.im + C2.im
  1058.                 ( op name=+ type=Number
  1059.                     ( template
  1060.                         ID=output
  1061.                         (type=Complex ID=input1)
  1062.                         (type=Complex ID=input2)
  1063.                     )
  1064.                     ( rewrite
  1065.                         (set(output.re,
  1066.                             (op name=+
  1067.                                 (op name=Real(input1))
  1068.                                 (op name=Real(input2))
  1069.                             )
  1070.                         ))
  1071.                         (set(output.im,
  1072.                             (op name=+
  1073.                                 (op name=Imag(input1))
  1074.                                 (op name=Imag(input2))
  1075.                             )
  1076.                         ))
  1077.                     )
  1078.                 )
  1079.                 /  C1 - C2 = C1.re - C2.re, C1.im - C2.im
  1080.                 /  elided for brevity
  1081.  
  1082.                            - 33 -
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.                            - 34 -
  1149.  
  1150.  
  1151.  
  1152. 8.  _P_r_i_m_i_t_i_v_e__C_l_a_s_s__L_i_b_r_a_r_y
  1153.  
  1154. This is the first cut at basic tools I think I want for
  1155. doing graphics work.  It is in an extremely condensed
  1156. pidgin.  These are all built-in classes and methods, library
  1157. classes are listed in the next section.
  1158.  
  1159.  
  1160. / Root object
  1161. (class
  1162.     ID=Object
  1163. )
  1164.  
  1165.  
  1166. / Number class
  1167. (class
  1168.     ID=Number
  1169.     super=Object
  1170.  
  1171.     / multi ops
  1172.     op Self +(Self, Self, multi Self)
  1173.     op Self *(Self, Self, multi Self)
  1174.     / binary
  1175.     op Self -(Self, Self)
  1176.     op Self /(Self, Self)
  1177.     / unary ops
  1178.     op Self -(Self)
  1179.     op Self sqrt(Self)
  1180.     op Self number(Boolean)
  1181.     / multi ops IS THIS THE RIGHT WAY TO DO THIS?
  1182.     / assignment op
  1183.     op Self Set(Self)
  1184. )
  1185.  
  1186. / Angle definition -
  1187. /   Number modular around circle
  1188. /   Uses signed 2's complement arithmetic to implement clean
  1189. /   angular arithmetic.  Going beyond 360 degrees rounds off
  1190. /   to beginning.  If these are implemented with signed chars,
  1191. /   all trig becomes table lookups.  Should complex numbers
  1192. /   subclass from Number or Angle?
  1193.  
  1194. (class
  1195.     ID=Angle
  1196.     super=Number
  1197. )
  1198.     / get Graphics Gems book and figure out ops
  1199.     / probably nothing needs to be overidden from Number
  1200.  
  1201. / Point class
  1202. (class
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.                            - 35 -
  1215.  
  1216.  
  1217.  
  1218.     ID=Point
  1219.     super=Number
  1220.  
  1221.     / creation op
  1222.     Point op Point(Number, Number, Number)
  1223.     / destruction ops
  1224.     Number op X(Point)
  1225.     Number op Y(Point)
  1226.     Number op Z(Point)
  1227.     / binary ops
  1228.     Point op +(Point, Point)
  1229.     Point op -(Point, Point)
  1230.     Point op *(Point, Number)
  1231.     Point op *(Number, Point)
  1232.     Point op *(Point, Matrix)
  1233.     Point op *(Matrix, Point)
  1234.     Point op Distance(Point, Point)
  1235.     / unary ops
  1236.     Point op -(Point)
  1237.     Point op sqrt(Point)
  1238.     Point op normalize(Point)
  1239.     Point op +(Point, Point, multi Point)
  1240. )
  1241.  
  1242.  
  1243. / Matrix class - 4x4 matrix for general 3-space xlations
  1244. / Do quaternions completely supercede this?
  1245. ( class
  1246.     ID=Matrix
  1247.     super=Number
  1248.  
  1249.     / creation op
  1250.     Matrix op Matrix(Number, Number, Number, ..., Number)   / 16
  1251.     Matrix op Matrix(Point, Point, Point, Point)        / 4x3
  1252.     / binary ops
  1253.     Matrix op *(Matrix, Matrix)
  1254.     / unary ops
  1255.     Matrix op invert(Matrix)
  1256.     Number op determinant(Matrix)
  1257.     Matrix op normalize(Matrix)
  1258.     Matrix op transpose(Matrix)
  1259. )
  1260.  
  1261. / random numbers.  Deliver a number between 0 & 1.
  1262. ( class
  1263.     ID=Random
  1264.     super=Number
  1265. )
  1266. / builtins: all the generators I can get with different distributions.
  1267. / Raid Knuth for algorithms.
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.                            - 36 -
  1281.  
  1282.  
  1283.  
  1284. / Range class
  1285. / A range is a pair of numbers.  The first must be lower than the second.
  1286. (class
  1287.     ID=Range
  1288.     super=Number
  1289.  
  1290.     / creation op
  1291.     Range op Range(Number, Number)
  1292.     / destruction ops
  1293.     Number op Lower(Range)
  1294.     Number op Upper(Range)
  1295.     / binary ops
  1296.     / Range op +(Range, Range)  / do these make sense?
  1297.     / Range op -(Range, Range)
  1298.     Range op Shift(Range, Number)   / shift range up or down
  1299.     Range op Scale(Range, Number)   / expand/contract range
  1300.     / in Dataset, shift and expand/contract are 'shift' and 'slide' ops
  1301. )
  1302.  
  1303.  
  1304. / Boolean class
  1305. (class
  1306.     ID=Boolean
  1307.     super=Object
  1308.  
  1309.     / multi ops
  1310.     op and(Boolean, multi Boolean)
  1311.     op nor(Boolean, multi Boolean)
  1312.     op xor(Boolean, multi Boolean)
  1313.     / unary ops
  1314.     op Boolean not(Boolean)
  1315.     op Boolean boolean(Number)
  1316.     op Boolean change(anything) / when input changes, become true
  1317.     / assignment op
  1318.     op Self Set(Self)
  1319. )
  1320.  
  1321. / built-in Booleans
  1322. stereo      / system is drawing in stereo mode - rw
  1323. left_eye    / system is updating left or right eye - ro
  1324. out_of_ram  / running on empty: do something! - ro
  1325. input_changed   / an input value to this operator changed - ro
  1326. switch1     / supplied hardware or window system
  1327. switch2
  1328. switch3
  1329. switch4
  1330.  
  1331. / Address of a node
  1332. / This class needs to be here to provide a specific type for
  1333. / indirect references to nodes.
  1334. (class
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.                            - 37 -
  1347.  
  1348.  
  1349.  
  1350.     ID=Address
  1351.     super=Object
  1352. )
  1353.  
  1354.  
  1355. / Error class: error exception handler
  1356. ( class
  1357.     ID=Error
  1358.     super=Object
  1359.  
  1360.     / On error #N, execute a program
  1361.     / Scoped for all siblings of this node and their descendants.
  1362.     ( Self op Self(Number, Void))       / get error
  1363.     ( Self op Self(Number, Void, Void)) / get error with message
  1364.     / Should the error number be a property?
  1365.     / If not specified, default to all?
  1366.     ( Self op Raise(Number))        / make error
  1367.     ( Self op Raise(Number, Void))      / make error with message
  1368. )
  1369.  
  1370.  
  1371. / Void object
  1372. / Various miscellaneous uses : rename it Glue? Clump?
  1373. (class
  1374.     ID=Void
  1375.     super=Object
  1376.     (property       // call all inputs in order, or simultaneously?
  1377.         ID=ordered
  1378.         type=Boolean
  1379.         inherited=False
  1380.     )
  1381.     (property       // when to execute
  1382.         ID=execute
  1383.         type=Boolean
  1384.     )
  1385.     (property       // copy tree or evaluate tree and copy value
  1386.         ID=evaluate
  1387.         type=Boolean
  1388.     )
  1389.     / clump of nodes
  1390.     (op Void call( multi type=anything ))       / do all
  1391.     / conditional
  1392.     (op Void cond( Boolean, type=anything, type=anything))  / if then else
  1393.  
  1394.     / tree surgery operation- can only rearrange at void "cut-points"
  1395.     / replace tree at address with tree void
  1396.     (op Void replace( Address type=Void), Void)
  1397.     / add tree to Void call op: add to collection
  1398.     (op Void add( Address(call) type=Void), Void)
  1399.     / maybe remove the most recently added tree?
  1400.  
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.                            - 38 -
  1413.  
  1414.  
  1415.  
  1416.     / top of World
  1417.     (op Void World( Void))  / top of world - visibility box
  1418.  
  1419.     / This is very goofy.  I don't like what it does to
  1420.     / tree storage at all.
  1421.     / copy value of property from address to address
  1422.     (op Void Setprop( Address (property name=xxx),
  1423.         Address (property name=xxx) )
  1424.     / copy values of all properties from address to address
  1425.     (op Void Setprop( Address (property name=xxx),
  1426.         Address (property name=xxx) )
  1427. )
  1428.  
  1429.  
  1430. / Unknown class
  1431. / internal data of unknown format
  1432. / used for things like network addresses, etc.
  1433. / not manipulable, just there.
  1434. ( class
  1435.     ID=Unknown
  1436.     super=Object
  1437. )
  1438.  
  1439.  
  1440.  
  1441.  
  1442. / Dataset class
  1443. / data array abstract superclass
  1444. (class
  1445.     ID=Dataset
  1446.     super=Object
  1447.     (property
  1448.         ID=dimensions
  1449.         type=Number
  1450.     )
  1451.     (property
  1452.         ID=indexable
  1453.         type=Boolean
  1454.     )
  1455.     (property
  1456.         ID=fractional
  1457.         type=Boolean
  1458.     )
  1459.     / OR
  1460.     /(property
  1461.     /   ID=indexing
  1462.     /   type=Enum(none,integer,fractional)
  1463.     /)
  1464.     / series of ranges for each dimension
  1465.     (property
  1466.         ID=infinite
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.                            - 39 -
  1479.  
  1480.  
  1481.  
  1482.         type=Boolean
  1483.     )
  1484.     (property
  1485.         ID=range0
  1486.         type=Range
  1487.     )
  1488.  
  1489.     / type of data held
  1490.     (property
  1491.         ID=datatype
  1492.         type=Address
  1493.     )
  1494.     / shift data up or down by factors
  1495.     (op Self Shift(Self, Number, ...))
  1496.     / stretch or shrink indices by scale factors
  1497.     (op Self Scale(Self, Number, ...))
  1498.  
  1499.     / concatenate two datasets to create a new one
  1500.     / they must have the same dimensionality, ranges, & types
  1501.     (op Self concat(Self, Self))
  1502. )
  1503.  
  1504. / real datasets you can use
  1505.  
  1506. / HDF scientific data set - NCSA HDF format - or abstract superclass as
  1507. / is deemed appropriate by sci-vis people.
  1508. /
  1509. / I have the HDF spec but haven't studied it much.
  1510. ( class
  1511.     ID=HDF
  1512.     super=dataset
  1513. )
  1514.  
  1515. / linear numerical set
  1516. ( class
  1517.     ID=Linear   / spectrum? 1D?
  1518.     super=Dataset
  1519. )
  1520.  
  1521. / random numbers?  I don't get it!
  1522. / ( class
  1523. /   ID=Random
  1524. /   super=Linear
  1525. / )
  1526.  
  1527. / Array
  1528. / 2D or 3D array of equally spaced data points
  1529. / may be formulaically derived (infinite=True).  Fractionally indexable
  1530. / (usually).
  1531. ( class
  1532.     ID=Texture
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.                            - 40 -
  1545.  
  1546.  
  1547.  
  1548.     super=Dataset
  1549.     (property
  1550.         ID=indexable
  1551.         type=Boolean
  1552.         value=True
  1553.     )
  1554. )
  1555.  
  1556. / bitmap - 2D monochrome Texture
  1557. ( class
  1558.     ID=Bitmap
  1559.     super=Texture
  1560.     ( property
  1561.         ID=Dimension
  1562.         type=Number
  1563.         value=2
  1564.     )
  1565.     ( property
  1566.         ID=Size
  1567.         type=Box
  1568.     )
  1569. )
  1570.  
  1571. / pixmap - 2D color Texture
  1572. ( class
  1573.     ID=Pixmap
  1574.     super=Texture
  1575.     ( property
  1576.         ID=Dimension
  1577.         type=Number
  1578.         value=2
  1579.     )
  1580.     ( property
  1581.         ID=Size
  1582.         type=Box
  1583.     )
  1584. )
  1585.  
  1586. / body - 3D color Texture - throughcut woodgrain etc.
  1587. / I've forgotten the special name for this, if there was one
  1588. ( class
  1589.     ID=Body
  1590.     super=Texture
  1591.     ( property
  1592.         ID=Dimension
  1593.         type=Number
  1594.         value=3
  1595.     )
  1596. )
  1597.  
  1598. / Drawable object
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.                            - 41 -
  1611.  
  1612.  
  1613.  
  1614. / visible screen object abstract superclass
  1615. (class
  1616.     ID=Drawable
  1617.     / for now, all the graphics you get.
  1618.     (property
  1619.         ID=color
  1620.         type=Point
  1621.     )
  1622.     / used for selecting several representations based on screen size
  1623.     / (that is, distance from user)
  1624.     / If this property is set, it overrides 3D placement stuff below.
  1625.     / If not set, it reflects the 3D placement stuff below.
  1626.     (property
  1627.         ID=screenbox
  1628.         type=Box
  1629.     )
  1630.     / when is this object to be drawn?
  1631.     (property
  1632.         ID=execute
  1633.         type=Boolean
  1634.     )
  1635.  
  1636.     / coordinate frame.
  1637.     / I thought I was using quaternions?  Boy, am I confused.
  1638.     (Property
  1639.         ID=frame
  1640.         Type=Point
  1641.     )
  1642.  
  1643.     / xlate, scale, rotate operations
  1644.     (op Self Scale(Self, Number X, Y, Z))
  1645.     (op Self Xlate(Self, Number X, Y, Z))
  1646.     (op Self Rotate(Self, Point Center, ???))
  1647.  
  1648.     / collection of drawables, inherit props from here
  1649.     (op Drawable call(Drawable, multi Drawable))
  1650.     / should be drawable?
  1651. )
  1652.  
  1653. / Line
  1654. ( class
  1655.     ID=Line
  1656.     Super=Drawable
  1657.  
  1658.     (Self op Self(Point, Point))    / two endpoints
  1659.     / Connect creates a line vertex
  1660.     (Self op Vertex(Point, Point))  / connector: allow painted textures
  1661.  
  1662. )
  1663. / Triangle
  1664. ( class
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.                            - 42 -
  1677.  
  1678.  
  1679.  
  1680.     ID=Triangle
  1681.     Super=Drawable
  1682.  
  1683.     (Self op Self(Point, Point, Point)) / three endpoints
  1684.     / Two triangles connect via a hinge
  1685.     (op Self Hinge (Point, Point))      / Allow spray-painted textures
  1686.     / should hinge be self or void?
  1687.     / hinge will usually use pointers
  1688.  
  1689. )
  1690.  
  1691. / Circle
  1692. ( class
  1693.     ID=Circle
  1694.     Super=Drawable
  1695.  
  1696.     (Self op Self(Point, Number))   / Center, radius
  1697.     / does connecting a circle make sense?  At given points?
  1698. )
  1699.  
  1700. / Sphere
  1701. ( class
  1702.     ID=Line
  1703.     Super=Drawable
  1704.  
  1705.     (Self op Self(Point, Number))   / Center, radius
  1706.     / does connecting a sphere make sense?  At given points?
  1707. )
  1708.  
  1709. / Don't hold your breath waiting for support for the following...
  1710. / Patch
  1711. / ( class
  1712. /   ID=Patch
  1713. /   Super=Drawable
  1714. /
  1715. /   / hellifino
  1716. / )
  1717.  
  1718. / Patch:Bezier
  1719. ( class
  1720. /   ID=Bezier
  1721. /   Super=Patch
  1722. /
  1723. /   / hellifino
  1724. / )
  1725. / Quadric
  1726. / ( class
  1727. /   ID=Quadric
  1728. /   Super=Drawable
  1729. /
  1730. /   (Self op Self())    / Equation inputs
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.                            - 43 -
  1743.  
  1744.  
  1745.  
  1746. /   (Self op Connect()) / Connect not allowed
  1747. / )
  1748. / Superquadric
  1749. / ( class
  1750. /   ID=Line
  1751. /   Super=Drawable
  1752. /
  1753. /   (Self op Self())    / equation inputs
  1754. /   (Self op Connect()) / Connect not allowed
  1755. / )
  1756. /
  1757.  
  1758. / Painted drawable object
  1759. / Overlay 2D or 3D Drawable with 2D or 3D texture
  1760.  
  1761. / Here we have the classic Trouble With Objects: doing a whole damn
  1762. / class definition just to make two different things interact.
  1763. ( class
  1764.     ID=Painted
  1765.     Super=Drawable
  1766.     Super=Texture
  1767.  
  1768.     / is this image sampled or just a flat bitmap?
  1769.     / real-time bitmaps will require the Intel DVI stuff or similar.
  1770.     / flat bitmaps are useful for hypertext
  1771.     / This can also be stroked Hershey fonts.
  1772.     ( property
  1773.         ID=flat
  1774.         type=Boolean
  1775.     )
  1776.  
  1777.     (op Apply(Texture, Drawable))
  1778. )
  1779.  
  1780. / Built-in textures are 2D: granite, 3D: wood.
  1781. / The apply operator re-runs the texturing operation with a new random
  1782. / seed, to get a new texture.
  1783.  
  1784. / Physical object
  1785. / bounding-box physics abstract superclass.
  1786. (class
  1787.     ID=Physical
  1788.     super=Object
  1789.     / motion
  1790.     (property
  1791.         ID=direction
  1792.         type=Point
  1793.     )
  1794.     (property
  1795.         ID=force
  1796.         type=Number
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.                            - 44 -
  1809.  
  1810.  
  1811.  
  1812.     )
  1813.     / spin
  1814.     (property
  1815.         ID=rotation_axis
  1816.         type=Point
  1817.     )
  1818.     (property
  1819.         ID=angular_momentum
  1820.         type=Number
  1821.     )
  1822. )
  1823.  
  1824.  
  1825. // Box definition - used for physical and screen bounding boxes
  1826. (class
  1827.     ID=Box
  1828.     input Point lower, upper
  1829.     (op Point ID=Lower(Box))
  1830.     (op Point ID=Upper(Box))
  1831.     (op Number ID=MinDist(Box))
  1832.     (op Number ID=MaxDist(Box))
  1833. )
  1834.  
  1835.  
  1836. / Quaternion class
  1837. / used in 3D rotation & placement work
  1838. (class
  1839.     ID=Quaternion
  1840.     super=Number
  1841.  
  1842.     / creation op
  1843.     Quaternion op Quaternion(Number, Number, Number, Number)
  1844.     / destruction ops
  1845.     Number op X(Quaternion)
  1846.     Number op I(Quaterion)
  1847.     Number op J(Quaterion)
  1848.     Number op K(Quaterion)
  1849.     / binary ops
  1850.     / go get the book, I don't know about these operations
  1851.     Quaterion op +(Quaterion, Quaterion)
  1852.     Quaterion op -(Quaterion, Quaterion)
  1853.     Quaterion op *(Quaterion, Number)
  1854.     Quaterion op *(Number, Quaterion)
  1855.     Quaterion op *(Quaterion, Matrix)
  1856.     Quaterion op *(Matrix, Quaterion)
  1857.     Quaterion op Distance(Quaterion, Quaterion)
  1858.     / unary ops
  1859.     Quaterion op -(Quaterion)
  1860.     Quaterion op sqrt(Quaterion)
  1861.     Quaterion op normalize(Quaterion)
  1862. )
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.                            - 45 -
  1875.  
  1876.  
  1877.  
  1878. / I/O port abstract superclass
  1879. ( class
  1880.     ID=IO
  1881.     super=Object
  1882.  
  1883.     ( property
  1884.         ID=readable
  1885.         Type=Boolean
  1886.     )
  1887.  
  1888.     ( property
  1889.         ID=writeable
  1890.         Type=Boolean
  1891.     )
  1892.  
  1893.     ( property
  1894.         ID=evaluate
  1895.         type=Boolean
  1896.     )
  1897.  
  1898.     ( Self op Self )
  1899.  
  1900.     / notification op to alert handler
  1901.     ( Boolean op New (Self))
  1902. )
  1903.  
  1904. / MIDI I/O port class- superclass only?  It seems to be useless by itself.
  1905. ( class
  1906.     ID=MidiPort
  1907.     Super=IO
  1908.     readable=True
  1909.     writeable=True
  1910. )
  1911.  
  1912. / Speaker I/O port class- superclass only?  It seems to be useless by itself.
  1913. / Not a loudspeaker, but a separate abstract noise-making entity.
  1914. ( class
  1915.     ID=SoundChannel
  1916.     Super=IO
  1917.  
  1918.     ( property
  1919.         ID=Position
  1920.         Type=Point
  1921.     )
  1922.     ( property
  1923.         ID=Volume
  1924.         Type=Number
  1925.     )
  1926. )
  1927.  
  1928. / Absolute one-directional input from 0 to 1
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.                            - 46 -
  1941.  
  1942.  
  1943.  
  1944. / A Slider itself is a number, but it inherits the New
  1945. / An analog joystick is two Sliders.
  1946. ( class
  1947.     ID=Slider
  1948.     Super=IO
  1949.     Super=Number
  1950.  
  1951.     readable=True
  1952.     writeable=False
  1953.  
  1954.     (Number op Value(Self))
  1955. )
  1956.  
  1957. / Relative one-directional input from 0 to 1
  1958. / A Delta itself is a number, but it inherits the New
  1959. / A mouse is two Deltas.
  1960. / An Nintendo joystick is two Deltas, using relative motion and an
  1961. / auto-acceleration input.
  1962. ( class
  1963.     ID=Delta
  1964.     Super=IO
  1965.     Super=Number
  1966.  
  1967.     readable=True
  1968.     writeable=False
  1969.  
  1970.     (Number op Value(Self))
  1971. )
  1972.  
  1973. / Switch
  1974. ( class
  1975.     ID=Switch
  1976.     Super=IO
  1977.     Super=Boolean
  1978.     readable=True
  1979.     writeable=False
  1980.  
  1981.     (Boolean op Value(Self))
  1982. )
  1983.  
  1984.  
  1985. / sound bite
  1986. ( class
  1987.     ID=SoundSample
  1988.     super=Linear
  1989.     super=SoundChannel
  1990.  
  1991.     (op Play(SoundSample, Speaker))
  1992.     (op Record(Speaker, SoundSample))
  1993.     / the use of the when-executed property to start and stop is a hack
  1994. )
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.                            - 47 -
  2007.  
  2008.  
  2009.  
  2010. / sound synthesizer patch: hardware-dependent.
  2011. / With Csound, an LPC parameter set.
  2012. ( class
  2013.     ID=SoundPatch
  2014.     super=Linear
  2015.     super=SoundChannel
  2016.  
  2017.     (op Play(SoundPatch, Speaker))
  2018.     / the use of the when-executed property to start and stop is a hack
  2019. )
  2020.  
  2021. / MIDI sound file
  2022. ( class
  2023.     ID=MidiSeq
  2024.     super=Dataset
  2025.     super=MidiPort
  2026.  
  2027.     / one dimension, indexable
  2028.     (op Play(MidiSeq, MidiPort))    / play Midi sequence out
  2029.     (op Record(MidiPort, MidiSeq))  / real-time capture?  good trick!
  2030.     / the use of the when-executed property to start and stop is a hack
  2031. )
  2032.  
  2033. / Network port abstract superclass
  2034. ( class
  2035.     ID=Network
  2036.     super=Object
  2037.  
  2038.     / This port has a unique channel number within the deck
  2039.     ( property
  2040.         ID=Channel
  2041.         type=Number
  2042.         writeable=False
  2043.     )
  2044.     / This protocol has guaranteed delivery
  2045.     ( property
  2046.         ID=Reliable
  2047.         type=Boolean
  2048.         writeable=False
  2049.     )
  2050.     / This protocol has ordered delivery
  2051.     ( property
  2052.         ID=Ordered
  2053.         type=Boolean
  2054.         writeable=False
  2055.     )
  2056.  
  2057.     / constructor & destructor ops
  2058.     / A network port's children are the most recent
  2059.     / incoming and outgoing trees which went across the net.
  2060.     / Void nodes are used as compartmental "cut-points".
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.                            - 48 -
  2073.  
  2074.  
  2075.  
  2076.     ( Self op Self (Void outgoing, incoming))
  2077.     ( Self op In (Self))
  2078.     ( Self op Out (Self))
  2079.  
  2080.     / send & receive programs
  2081.     / usually, the port is accessed via a Refer node
  2082.     ( Void op Send (Self, Void))
  2083.     ( Void op Receive (Self, Void))
  2084.  
  2085.     / notification op to alert handler
  2086.     ( Boolean op New (Self))
  2087. )
  2088.  
  2089. / Virtual circuit port abstract superclass
  2090. ( class
  2091.     ID=VirtualCircuit
  2092.     super=Network
  2093.  
  2094.     / Inherit channel number
  2095.     / This port initiates or accepts connections
  2096.     ( property
  2097.         ID=Initiate
  2098.         type=Boolean
  2099.         writeable=False
  2100.     )
  2101. )
  2102.  
  2103. / Datagram port abstract superclass
  2104. ( class
  2105.     ID=Datagram
  2106.     super=Network
  2107.  
  2108. )
  2109.  
  2110. / TCP/IP UDP network port
  2111. / 5D program directly in UDP packet, no intermediate protocol layer
  2112. / A channel number is a UDP port number.  It is assigned by the deck
  2113. / when the program is digested.  The deck must upload the tree with
  2114. / the network object to an application to inform the application what
  2115. / the subsidiary port number is.
  2116. ( class
  2117.     ID=UDP
  2118.     super=Datagram
  2119.     / other host IP & Port number
  2120.     ( property
  2121.         ID=OtherIP
  2122.         type=Unknown        / magic secret data type
  2123.         / value will be a text string, with format for RFC xxx
  2124.         / proto-assigner
  2125.     )
  2126. )
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.                            - 49 -
  2139.  
  2140.  
  2141.  
  2142. / TCP/IP TCP network port
  2143. / 1 port # per channel
  2144. ( class
  2145.     ID=TCP
  2146.     super=Network
  2147.     / other host IP & Port number
  2148.     ( property
  2149.         ID=OtherIP
  2150.         type=Unknown        / magic secret data type
  2151.         / value will be a text string, with format for RFC xxx
  2152.         / proto-assigner
  2153.     )
  2154. )
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.                                   - 18 -
  2231.  
  2232.  
  2233.  
  2234.                 /  C1 * C2 = (C1.re * C2.re) - (C1.im * C2.im),
  2235.                              (C1.re * C2.im) + (C2.re * C1.im),
  2236.                 ( op name=* type=Number
  2237.                     ( template
  2238.                         ID=output
  2239.                         (type=Complex ID=input1)
  2240.                         (type=Complex ID=input2)
  2241.                     )
  2242.                     ( rewrite
  2243.                         (set(output.re,
  2244.                             (op name=-
  2245.                                 (op name=*
  2246.                                     (op name=Real(input1))
  2247.                                     (op name=Real(input2))
  2248.                                 )
  2249.                                 (op name=*
  2250.                                     (op name=Imag(input1))
  2251.                                     (op name=Imag(input2))
  2252.                                 )
  2253.                             )
  2254.                         ))
  2255.                         (set(output.im,
  2256.                             (op name=+
  2257.                                 (op name=*
  2258.                                     (op name=Real(input1))
  2259.                                     (op name=Imag(input2))
  2260.                                 )
  2261.                                 (op name=*
  2262.                                     (op name=Imag(input1))
  2263.                                     (op name=Real(input2))
  2264.                                 )
  2265.                             )
  2266.                         ))
  2267.                     )
  2268.                 )
  2269.                 / Square(Complex input) -> *(input, input)
  2270.                 ( op name=Square type=Complex
  2271.                     ( template
  2272.                         ID=output
  2273.                         (type=Complex ID=input)
  2274.                     )
  2275.                     ( rewrite
  2276.                         (set (output,
  2277.                             (op name=*
  2278.                                 (input)
  2279.                                 (input)
  2280.                             )
  2281.                         ))
  2282.                     )
  2283.                 )
  2284.             )
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.                                   - 19 -
  2297.  
  2298.  
  2299.  
  2300.        The Complex object contains two numbers, and implements
  2301.        complex arithmetic.  Complex subclasses from Number, because
  2302.        it must be able to rewrite itself into Number objects.
  2303.        Square rewrites itself into Complex, while all the other
  2304.        operators rewrite themselves into Complex or Number.
  2305.        Complex objects must be rewritten into Numbers before their
  2306.        components may be accessed.  Thus, we can be sure that all
  2307.        invocations of Complex are eventually rewritten into Number,
  2308.        a primitive class.
  2309.  
  2310.        Note that the definitions for addition and subtraction are
  2311.        redundant.  The input declaration section says that a
  2312.        Complex is an aggregation of two Numbers, in order.  The
  2313.        operator inheritance mechanism interacts with this
  2314.        declaration to automatically derive the addition and
  2315.        subtraction operators defined above.
  2316.  
  2317.        The 5D system generates an arithmetic tree of primitive
  2318.        objects working from the template patterns in user-defined
  2319.        objects in an iterative algorithm.  The program tree
  2320.  
  2321.            Complex C1, C2, C3
  2322.            label: Real(plus(C3, plus(C1, C2)))
  2323.            Imag(label ^)
  2324.        generates the two Numbers
  2325.  
  2326.            Real(plus(Real(C3), plus(Real(C1), Real(C2))))
  2327.            Imag(plus(Imag(C3), plus(Imag(C1), Imag(C2))))
  2328.        which may be fed into I/O operations at the top of the
  2329.        lattice.
  2330.  
  2331.        4.8.7  _D_r_a_w_a_b_l_e__O_b_j_e_c_t_s
  2332.        The above classes only implement numerical operations.  The
  2333.        Drawable class possesses visual properties such as color and
  2334.        position.  The position property is a Point.  The color
  2335.        property is a Point in RGB color space.  A property may be
  2336.        an object, or a arithmetic tree of objects.  Property
  2337.        objects can have no properties themselves.
  2338.  
  2339.        The Triangle is a built-in object subclassed off of
  2340.        Drawable.  It consists of three Points.  Since a Point is
  2341.        composed of three Numbers, a Triangle may have nine
  2342.        arithmetic trees underneath it, and constantly change shape
  2343.        as those subtrees change value.  A 3D modelling program
  2344.        might use this to rubber-band changes in a 3D shape in
  2345.        response to numerical input devices, or use feedback to
  2346.        implement jiggly objects.
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.                                   - 20 -
  2363.  
  2364.  
  2365.  
  2366.        4.9  _P_r_o_g_r_a_m__I_D__S_c_o_p_i_n_g
  2367.  
  2368.        The visibility of IDs is scoped two ways in program trees:
  2369.        by tree structure, and by program source.
  2370.  
  2371.        4.9.1  _T_r_e_e_-_s_t_r_u_c_t_u_r_e_d__s_c_o_p_i_n_g
  2372.        Outside of a class definition, the ID of a node is visible
  2373.        to a node's siblings and their children.  Thus,
  2374.  
  2375.        Inside a class definition, things are different:  the inputs
  2376.        and outputs of the object have special IDs, and IDs declared
  2377.        in a method's template are visible within that method's
  2378.        rewrite rule.  This allows the template to describe a
  2379.        complex tree, and the rewrite rule to tear it apart and
  2380.        restructure it.
  2381.  
  2382.        4.9.2  _P_r_o_g_r_a_m_-_s_o_u_r_c_e__s_c_o_p_i_n_g
  2383.        Different sub-trees in the same scene can be downloaded over
  2384.        the network from different applications.  If there were just
  2385.        one tree-scoped ID name space, there would be severe
  2386.        problems with different programs innocently (or maliciously)
  2387.        affecting each other's scene members.  Thus, ID names are
  2388.        also "sealed off" for each program source.  A sub-program
  2389.        from a different network source may only refer to nodes
  2390.        downloaded from that network source, and the primitive
  2391.        objects.  A redefinition of a primitive object is also
  2392.        visible, since it is referred to by the name of a primitive
  2393.        object.
  2394.  
  2395.        A parent node may use relative ID addressing to walk a tree
  2396.        down to a child node received over the network.  This is
  2397.        only a feasible coding technique if the child tree has been
  2398.        "syntax-checked" against a template.
  2399.  
  2400.        4.10  _C_l_a_s_s__d_e_f_i_n_i_t_i_o_n__s_c_o_p_i_n_g
  2401.  
  2402.        A class definition occurs under a program tree node.  Thus,
  2403.        it is only available under that parent node.  Two
  2404.        definitions of the same class may not be siblings.  However,
  2405.        a class may be redefined in a child tree.  The class
  2406.        redefinition may only have one superclass, the parent
  2407.        definition.  The redefinition may add, delete, or change
  2408.        operators or properties.  The parent's version of overridden
  2409.        operators may be invoked within more elaborate
  2410.        implementations.  For example, the "hinge" operator which
  2411.        connects polygons may be redefined to draw a line along the
  2412.        edge of the hinge, by redefining the class Drawable and
  2413.        overriding the "hinge" definition.
  2414.  
  2415.        In a class definition the operator and property definition
  2416.        nodes may use the Type= to select the special IDs Parent or
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.                                   - 21 -
  2429.  
  2430.  
  2431.  
  2432.        Self. In an operator definition, Self indicates that the
  2433.        type of an operation is that of the class or of any derived
  2434.        subclass.  Examination of the Number and Angle classes shows
  2435.        an example of this.  The Number operators are defined as
  2436.        type Self.  Since Angle derives from Number, all the
  2437.        operators from Number simply appear as "Angle + Angle is
  2438.        Angle" etc.  without being respecified in the Angle class
  2439.        definition.
  2440.  
  2441.        Scoping describes which other objects an object definition
  2442.        may refer to.  There are four forms of references: rewrite,
  2443.        aggregation, data, and property.  Here are the scoping rules
  2444.        for each type of reference:
  2445.  
  2446.        4.10.1  _R_e_w_r_i_t_e__S_c_o_p_i_n_g
  2447.        Rewrite reference scoping controls what a method definition
  2448.        can rewrite itself into.  The example class Complex rewrites
  2449.        itself into Complex or Number.  Here are the replacement
  2450.        scoping rules:
  2451.  
  2452.        Self                An object may replace an operation on
  2453.                            itself with another expression of its
  2454.                            own type.  For instance, Complex
  2455.                            replaces the square(Complex) operation
  2456.                            with multiply(input1, input1).
  2457.  
  2458.        Super               An object may also replace an operation
  2459.                            with an expression of its super-class's
  2460.                            type, and on up the line to Object.  For
  2461.                            instance, Complex replaces the Real and
  2462.                            Imag operators with expressions of type
  2463.                            Number.  Complex cannot replace any
  2464.                            invocations with operators of type
  2465.                            Object, because Object has no operators.
  2466.  
  2467.        Obviously, if a class can rewrite itself into any other
  2468.        class, a circular definition would cause an operation to be
  2469.        rewritten endlessly.  While all such errors can be
  2470.        discovered automatically, it is very difficult to remove
  2471.        them from a design.  This rewrite policy avoids this problem
  2472.        entirely by making it impossible for circular references to
  2473.        exist.
  2474.  
  2475.        Note: inside a rewrite rule, all known classes may be used
  2476.        for interior operations. [ I think this deserves its own
  2477.        heading, but I don't know quite where. ]
  2478.  
  2479.        4.10.2  _A_g_g_r_e_g_a_t_e__S_c_o_p_i_n_g
  2480.        Aggregation reference scoping controls what objects may be
  2481.        input to an operator rule.  Above, Complex accepts Complex
  2482.        and Number as input.  Here are the aggregation scoping
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.                                   - 22 -
  2495.  
  2496.  
  2497.  
  2498.        rules:
  2499.  
  2500.        Self                An object may have objects of its own
  2501.                            type as inputs.  For instance, Complex
  2502.                            accepts square(Complex).
  2503.  
  2504.        Super               An object may have objects of its
  2505.                            various superclasses as inputs.  For
  2506.                            instance, the Complex object creation
  2507.                            rule accepts two Numbers as inputs and
  2508.                            type-casts them into a Complex.
  2509.  
  2510.        Sibling             An object may accept _s_i_b_l_i_n_g objects
  2511.                            (other objects with the same
  2512.                            superclasses) as inputs.
  2513.  
  2514.        In rewrite rules, the special type Parent refers to the
  2515.        parent class from whom an operator was inherited.  This is
  2516.        used in operator re-defines in classes which override a
  2517.        parent class of the same name.  It allows invoking the
  2518.        parent's operator definition in the middle of the child's
  2519.        operator definition.
  2520.  
  2521.        These rules are somewhat arbitrary. They force the class
  2522.        designer to think through very carefully the objectives of
  2523.        the project, and to understand more fully the "Buddha
  2524.        Nature" of the class structure.
  2525.  
  2526.        4.10.3  _D_a_t_a__S_c_o_p_i_n_g
  2527.        Each object defined in a Data sections of a class must have
  2528.        an ID which starts with a $ sign.  References to ID's
  2529.        starting with $ sign are scoped to within the class
  2530.        definition.  [ This is non-orthogonal with the rest of the
  2531.        scoping rules.  Do it some other way.  Maybe myclass::ID? ]
  2532.  
  2533.        4.10.4  _P_r_o_p_e_r_t_y__S_c_o_p_i_n_g
  2534.  
  2535.        4.10.4.1  _P_r_o_p_e_r_t_y__N_a_m_e_s
  2536.        Properties are not subject to a unique name space.
  2537.        Different classes may use the same name to define properties
  2538.        unique to themselves.  If two different classes both define
  2539.        a property and are combined to derive a subclass, the two
  2540.        different properties may be disambiguated by the
  2541.        _s_u_p_e_r=ppppaaaarrrreeeennnntttt keyword.  The data section of a class
  2542.        definition is private; the properties of aggregated data
  2543.        types are not available.
  2544.  
  2545.        4.10.4.2  _P_r_o_p_e_r_t_y__T_y_p_e_s
  2546.        Properties may be of any type which has no properties.  The
  2547.        issue here is that if a property can have a property, then
  2548.        it can go into a loop attempting to evaluate the original
  2549.        property.  Properties are second class citizens in 5D.  They
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.                                   - 23 -
  2561.  
  2562.  
  2563.  
  2564.        are intended as simple adornments directing the evaluation
  2565.        of real tree nodes. If a property has important information
  2566.        to contribute to the execution of a program, it should be a
  2567.        real tree node instead.
  2568.  
  2569.        To enforce language simplicity, types of properties may be
  2570.        restricted to something.  The siblings of a superclass might
  2571.        work out, as might a special sub-tree of simple types in the
  2572.        core class hierarchy.
  2573.  
  2574.        4.10.4.3  _P_r_o_p_e_r_t_y__I_n_h_e_r_i_t_a_n_c_e
  2575.        Properties are inherited dynamically, not statically.  When
  2576.        trees are executed via pointers, they inherit their
  2577.        properties from the pointing node, not via their original
  2578.        parent.
  2579.  
  2580.        4.10.5  _A_d_d_r_e_s_s_i_n_g__i_s_s_u_e_s
  2581.        Suppose that sender A creates a tree that accepts data from
  2582.        sender B. B's data may only appear under A's world according
  2583.        to A's wishes.  A may not remove B's data directly, _s_i_n_c_e _i_t
  2584.        _c_a_n_n_o_t _a_d_d_r_e_s_s _i_t.  However, A must instead remove A's trees
  2585.        which hold B's data.
  2586.  
  2587.        This example brings up another point:  dynamic references to
  2588.        a non-existent ID are a run-time error.  The Exception class
  2589.        handles this type of problem.  The extant expection handler
  2590.        receives the code for a non-existent ID reference, and acts
  2591.        appropriately.  Static references are not an error.  That
  2592.        is, the disappearance of a named node does not automatically
  2593.        cause exceptions for all the nodes pointing to it.  A new
  2594.        version of the node, or another node somewhere else with the
  2595.        same ID, may be interposed without mishap.  A remote
  2596.        application which performs this sort of skullduggery should
  2597.        put execution interlocks in place beforehand.
  2598.  
  2599.        Program references may use IDs with relative indexing:  an
  2600.        ID may be followed by zero or more /_n_u_m_b_e_r strings, each
  2601.        number an index at successive levels of the tree.  Relative
  2602.        indexing only goes down the tree, and ignores network
  2603.        scoping rule.  Thus, a program may accept a network packet
  2604.        and peer at its contents.  It also allows a complex
  2605.        polyhedron to avoid giving an ID to each component when
  2606.        specifying interconnections, thus saving much space in
  2607.        transmission.
  2608.  
  2609.        4.10.6  _A_d_d_r_e_s_s_i_n_g__U_s_e_s
  2610.        The ID space is segmented for various "control" trees.  For
  2611.        example, one small range of IDs is used inside tree
  2612.        definitions to refer to the inputs of that tree.  Another
  2613.        range of IDs is used to indicate shared-memory bitmaps for
  2614.        concurrent access by 5D and a 2D imaging system (X,
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.                                   - 24 -
  2627.  
  2628.  
  2629.  
  2630.        PostScript, video) on the same machine.
  2631.  
  2632.  
  2633.        5.  _L_a_n_g_u_a_g_e__I_m_p_l_e_m_e_n_t_a_t_i_o_n__A_r_c_h_i_t_e_c_t_u_r_e
  2634.  
  2635.        5D may be fully interpreted, not that you'd want to.  A full
  2636.        interpreter can not build a sortable polygon database, and
  2637.        thus cannot implement hidden surfaces.  It would also be
  2638.        very slow.  A partial interpreter can build a polygon
  2639.        database. This technique analyzes the world description tree
  2640.        and decomposes it into jobs to be done at different times.
  2641.        The section below describes this technique in more detail.
  2642.  
  2643.        The language is also intended to be "hot compiled", that is,
  2644.        the deck software can analyze a tree and generate binary
  2645.        code to implement that tree.  If it creates nothing more
  2646.        than a string of subroutine calls to the op-code handlers of
  2647.        the interpreter, it still dissolves away the interpretive
  2648.        loop.  A compiler can optimize different built-in types;
  2649.        i.e. it can do constant folding for matric operations for
  2650.        which portions of a matrix are known.  5D is also targeted
  2651.        for ease of compilation on parallel processors.  The
  2652.        language attempts to minimize interactions between nodes.  [
  2653.        This will require much analysis by experts in parallel
  2654.        software. ]
  2655.  
  2656.        5.1  _L_a_n_g_u_a_g_e__d_e_s_i_g_n__i_s_s_u_e_s
  2657.  
  2658.        5D is intended as a basis for real-time simulation.  As
  2659.        such, the power and elegance of abstract research languages
  2660.        is unfortunately not available.  Languages such as
  2661.        Smalltalk, Prolog, Actor, etc.  are beautifully simple and
  2662.        dense, but require unpredictable amounts of CPU time to
  2663.        implement their constructs.  5D's language constructs must
  2664.        be implementable in a predictable manner.  Every operation
  2665.        must require O(1) amount of time to execute.
  2666.  
  2667.        5D is designed to be efficient in the amount of space used
  2668.        to store 5D programs, and thus efficent in network
  2669.        transmission time.  It is also designed to be efficient to
  2670.        execute compiled or digested 5D code.  After the simulation
  2671.        clock starts, 5D must keep the beat.  Slow digestion of 5D
  2672.        code, and the prodigious use of RAM to store pre-computed
  2673.        data, is unfortunate but necessary.
  2674.  
  2675.        Also, real-time predictability outvotes run-time efficiency.
  2676.        For example, whether it would be more efficient to use
  2677.        garbage collection rather than freeing memory on the fly is
  2678.        immaterial.  The screen cannot stop updating at random
  2679.        intervals to do a GC sweep.
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.                                   - 25 -
  2693.  
  2694.  
  2695.  
  2696.        5.2  _L_o_w_-_e_n_d__s_y_s_t_e_m__i_m_p_l_e_m_e_n_t_a_t_i_o_n__s_t_r_a_t_e_g_y
  2697.  
  2698.        5D is targeted initially at low-MIPS desktop computers such
  2699.        as the 386 PC and the Mac.  A single-CPU frame buffer-based
  2700.        computer will implement 5D as a classic simulation system.
  2701.        A multi-tasking co-routine package supports a variety of
  2702.        subsystems which implement different aspects of the deck:
  2703.        sound I/O, positional input devices, force-feedback events,
  2704.        network I/O, and last but not least, screen update.  These
  2705.        subsystems sleep on different events:  I/O interrupts,
  2706.        timeouts, and software-defined events.  Each subsystem
  2707.        maintains a task list.  It sleeps on one or more events and
  2708.        does a task list each time that event occurs.  The network
  2709.        I/O system accepts trees from outside and adds them to the
  2710.        world tree.  Each subsystem must be able to insert new tasks
  2711.        and delete old tasks on the fly, in response to dynamic
  2712.        editing of the tree.
  2713.  
  2714.        The polygon database has 2 levels:
  2715.  
  2716.           +o a list of high-level objects which can change their
  2717.             relative distances and orientations,
  2718.  
  2719.           +o where each object is solid and does not change shape.
  2720.  
  2721.        The high-level list must be sorted for each mono or stereo
  2722.        screen refresh.  Each static object is stored in a Binary
  2723.        Space Partition database [ ref ].  (The BSP algorithm does a
  2724.        large majority of the polygon sorting work independent of
  2725.        the viewpoint.  Animating a static object consists of pre-
  2726.        sorting it, then walking the last mile over and over, thus
  2727.        considerably speeding up screen refreshes.)  Each screen
  2728.        refresh must sort the list of high-level objects in 3-space
  2729.        (probably by bounding boxes), and do a fast BSP viewpoint of
  2730.        the polygons in each static object.  Depending on the screen
  2731.        size and scene complexity, object-first or scan-line-first
  2732.        rendering may be appropriate, and the renderer may want to
  2733.        switch between them dynamically.  For stereo rendering it
  2734.        may make sense to walk through the database rendering both
  2735.        screens, or to walk through it twice doing one screen at a
  2736.        time.
  2737.  
  2738.        Practical experience [ref: Graphics Interface '90, "The
  2739.        DataPaper", Green & Shaw] shows that applying BSP to a
  2740.        completely static scene winds up fracturing the scene into
  2741.        an immense number of polygons, and in fact the 2-level
  2742.        scheme ("clumpy BSP?") is preferable in this case also.
  2743.  
  2744.        In any event, the Graphics Gems software distribution and
  2745.        the VOGLE portable 3D library will provide the source code
  2746.        for the first pass at a renderer.
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.                                   - 26 -
  2759.  
  2760.  
  2761.  
  2762.        5.2.1  _S_t_a_t_e__V_e_c_t_o_r_s
  2763.        For debugging worlds, and doing animation, it is necessary
  2764.        to maintain a state vector of the execution of a world.
  2765.        Network control can stop and start execution, and "play" the
  2766.        sequence of frames forward and back.
  2767.  
  2768.        Because tree evaluations are triggered by multiple clocks
  2769.        and asynchronous events, there is not one state vector, but
  2770.        instead a "time line" of events and state vectors for the
  2771.        appropriate tree.  [This is going to be hairy!]  These state
  2772.        vectors are accessible to 5D and are used by the World
  2773.        Manager to "swap out" world descriptions as the user wanders
  2774.        between them.
  2775.  
  2776.        5.3  _N_e_t_w_o_r_k__C_o_m_m_u_n_i_c_a_t_i_o_n_s
  2777.  
  2778.        A 5D program is read in from a file or a network connection.
  2779.        Decks communicate across networks by sending 5D trees.
  2780.        Communication circuits are point-to-point in 5D terms but
  2781.        may be multi-drop underneath.  That is, it may receive UDP
  2782.        broadcasts but only receives from host X under host X's
  2783.        connection object.  Thus, it must have a separate UDP
  2784.        broadcast connection object for each incoming host.
  2785.  
  2786.        When received, a tree may be examined and then executed or
  2787.        rejected, or it may just sit in a holding place for
  2788.        reference.  The World Manager needs to accept downloaded
  2789.        trees and splice them under a "top of world" partition.
  2790.        MazeWar merely needs to examine the latest status message
  2791.        from all other players.
  2792.  
  2793.        Trees are examined with the 5D _t_e_m_p_l_a_t_e facility:  a
  2794.        received tree may be checked against a template as a form of
  2795.        syntax check.  If it passes the check, the receiving parent
  2796.        tree may choose to execute it.  [ We may want to add the
  2797.        boolean Authenticated as a property of a received program.
  2798.        The receiver can then take various actions if a program did
  2799.        not have the right magic encrypted checksum. ]
  2800.  
  2801.        Groupware and Cyberspace applications are not well served by
  2802.        the common network protocols; 5D may eventually include a
  2803.        mutated form of ISIS, IRC, Kerberos, MUD, or all four.  MUD
  2804.        would form a nice permanent object repository for 5D, while
  2805.        something like the Habitat system could be built running 5D
  2806.        over IRC.
  2807.  
  2808.        5.3.1  _R_P_C__c_o_m_p_i_l_e_r
  2809.        For doing basic application-deck pair applications, a
  2810.        library-building compiler like the one SUN distributes with
  2811.        NeWS would be very useful.  [ I read about it in a SUN tech
  2812.        papers book: I haven't actually used it. ]
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.                                   - 27 -
  2825.  
  2826.  
  2827.  
  2828.        5.3.2  _C_C_K_:__C_y_b_e_r_s_p_a_c_e__C_o_n_s_t_r_u_c_t_i_o_n__K_i_t
  2829.        The effort involved in debugging a client-server network
  2830.        protocol is surprisingly large; we're going to need a
  2831.        protocol design & debug system for doing many-to-many 5D
  2832.        network applications.  It should have a method for tracing
  2833.        network messages to & from a deck, and stopping & starting
  2834.        operations via network control.  ESTELLE [ ref ??? ] is a
  2835.        protocol design language used for describing portions of the
  2836.        OSI protocol stack. There are ESTELLE simulators; this would
  2837.        make a handy addition to the CCK.
  2838.  
  2839.        5.3.3  _N_e_t_w_o_r_k__O_b_j_e_c_t
  2840.        The Network object is an abstract superclass for defining
  2841.        network protocols for use with 5D.  The object has a channel
  2842.        number as a property.  Each network connection has a unique
  2843.        number.  This number is used to multiplex communications
  2844.        between multiple endpoints in the deck to the outside world.
  2845.        Whether a network port initiates or receives connections is
  2846.        a property, as is whether the protocol uses reliable and
  2847.        ordered delivery.
  2848.  
  2849.        A networked deck starts up with various tasks such as
  2850.        calibrating I/O devices and adjusting speaker volumes.  It
  2851.        then starts a program tree whose sole purpose is to open a
  2852.        receptive network connection in each protocol the deck
  2853.        supports.
  2854.  
  2855.        5.3.3.1  _T_C_P_/_U_D_P__n_e_t_w_o_r_k_i_n_g
  2856.        5D uses RFC [ XXX ] to dynamically register the well-known
  2857.        TCP & UDP port numbers for these main ports.  It can also
  2858.        assign channel numbers to subsidiary network sockets
  2859.        dynamically.  Any program when creates subsidiary sockets
  2860.        with auto-assigned channels must upload the trees with the
  2861.        sockets, to find out their protocol port numbers.  A program
  2862.        may also pre-assign port numbers and hope it won't clash
  2863.        with anything else. This technique must be used in UDP
  2864.        broadcast applications like MazeWar, because every deck must
  2865.        use the same port number.
  2866.  
  2867.        [ A reliable broadcast protocol could be done by relying on
  2868.        a main application to ensure that all other decks got your
  2869.        message, and simply making sure that the main application
  2870.        got it.  This follows the dictum of philosophy of off-
  2871.        loading non-interactive work to the application. ]
  2872.  
  2873.        5.4  _W_o_r_l_d__M_a_n_a_g_e_r
  2874.  
  2875.        The World Manager is just the main 5D application.  It makes
  2876.        sub-worlds available to the user.  A static WM is loaded
  2877.        from a file and stores one or more sub-worlds in memory.
  2878.  
  2879.  
  2880.  
  2881.  
  2882.  
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.                                   - 28 -
  2891.  
  2892.  
  2893.  
  2894.        5.4.1  _H_a_l_l_w_a_y
  2895.        The prototype implementation of the WM is the _H_a_l_l_w_a_y
  2896.        (inspired by various "Rooms" systems).  The user moves down
  2897.        a hallway of doors. Each door has some label or icon.  The
  2898.        user selects the doorknob, label, or icon and pops into that
  2899.        world.
  2900.  
  2901.        Under file-based 5D, the world is just there in RAM, waiting
  2902.        to run.  Under network-based 5D, there is usually a remote
  2903.        application program on a computer for each world.  This
  2904.        application handles permanent data storage and complex
  2905.        calculation work not easily done with 5D.  In general, the
  2906.        application communicates asynchronously with the world,
  2907.        implementing all synchronous user interface feedback in
  2908.        downloaded 5D.
  2909.  
  2910.        5.4.2  _N_e_t_w_o_r_k_e_d__W_M
  2911.        A dynamic networked WM downloads world trees across the
  2912.        network from a remote master program for this deck.
  2913.  
  2914.        In the Hallway, selecting the doorknob causes your WM to
  2915.        send a message to the master, which then fires up the
  2916.        program for your selected world.  The program contacts your
  2917.        WM and downloads the world tree.  The WM accepts the world,
  2918.        stuffs it under a "top-of-world" (class Void) node, and
  2919.        turns it on.
  2920.  
  2921.        When you exit the world, the WM can destroy it or keep it
  2922.        around.  The WM can manage memory usage by uploading the
  2923.        current state of a world to its counterpart and deleting it.
  2924.        When you want to re-enter it, the WM downloads it again.
  2925.        Before this, the WM may "swap out" your previous world.
  2926.  
  2927.        You may only traverse worlds by passing through the Hallway.
  2928.        There's no technical reason for this, it's merely because
  2929.        the Hallway's worlds are not conceptually connected.  A
  2930.        world may implement its own suite of connected environments
  2931.        and traverse them in any order.  A house may have doors,
  2932.        windows, ventilator shafts and secret passages for you to
  2933.        traverse.
  2934.  
  2935.  
  2936.        6.  _T_e_x_t
  2937.  
  2938.        5D does not contain a textual abstraction, a font database,
  2939.        or support for typewriter keyboards.  There are two possible
  2940.        uses for text in 5D:  2-dimensional text and 3-dimensional
  2941.        text, with very different aims.  Statistically speaking, 2D
  2942.        text is rendered, read, and erased.  3D text, on the other
  2943.        hand, tends to be permanent.  It is generally used as a
  2944.        label in a larger 3D model.  The low volatility of 3D text
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.                                   - 29 -
  2957.  
  2958.  
  2959.  
  2960.        does not merit devoting scarce permanent deck resources to
  2961.        fonts.  It is better handled as a library tree used by
  2962.        applications.  2D text is not supported for 2 reasons:
  2963.  
  2964.           +o 2D textual graphics has been addressed already by many
  2965.             systems: Tex/Dvi, Postscript, troff, the X Window
  2966.             System, etc.  Many of these systems have freeware
  2967.             versions which could be easily altered to support 2D
  2968.             graphics under 5D.  In particular, it would be quite
  2969.             easy to create an X window server which moves flat
  2970.             bitmaps around in 3-space.  This could be connected to
  2971.             5D via 5D networking or by cohabiting in the same
  2972.             operating system.  A multi-processor Mach system with
  2973.             one CPU running the X stuff and one running 5D would
  2974.             make a great hypermedia system.  (Throw another CPU on
  2975.             the fire!)
  2976.  
  2977.           +o The "official" 5D core language specification only
  2978.             supports application features which are widely
  2979.             recognized as the one right way to do things, or as one
  2980.             of two or three commonly accepted methods.  Text is a
  2981.             mess. There are upwards of 20 European Roman-Arabic
  2982.             keyboards alone.  Japan has 3 alphabets.  Some
  2983.             lettering goes right-to-left, some up-to-down.
  2984.             Calligraphic lettering apparently requires an iterative
  2985.             method to match up lines between symbols.  We don't
  2986.             want to keep adding new text "standards" every six
  2987.             months, duplicating the work that's been done for other
  2988.             text-processing systems.
  2989.  
  2990.        If the specified functionality of a low-end deck ends up
  2991.        including a CD-ROM of library materials, the core library
  2992.        will include the Hershey fonts, and some basic Adobe-style
  2993.        outline fonts, and simple 3D CSG-based text construction
  2994.        operators.
  2995.  
  2996.        [It might work out for keyboards to just be objects with
  2997.        many, many switches.  Another object might interpret these
  2998.        into an ASCII dataset, for network communication.]
  2999.  
  3000.  
  3001.        7.  _T_e_r_r_a_F_o_r_m_e_r
  3002.  
  3003.        The TTTTeeeerrrrrrrraaaaFFFFoooorrrrmmmmeeeerrrr is a visual programming CASE system for 5D
  3004.        trees.  It is a 5D program which presents a tree as a 3D
  3005.        scene, using translucent structure blocks to display several
  3006.        levels of structure simultaneously.  Someday.
  3007.  
  3008.        But for now, it's a standard 2D window system application.
  3009.        You are able to browse and edit the program tree, and browse
  3010.        the class inheritance lattice.  The tree and lattice windows
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.                                   - 30 -
  3023.  
  3024.  
  3025.  
  3026.        use a space-efficient method to display these data
  3027.        structures.
  3028.  
  3029.        7.1  _T_r_e_e__w_i_n_d_o_w
  3030.  
  3031.        The tree window show many levels of a tree, starting at a
  3032.        particular node in the tree.  The tree (+ ID=sum (*(1,2),3))
  3033.        is shown as:
  3034.  
  3035.  
  3036.        ------------------------------------------------------
  3037.        | +                                              sum |
  3038.        | -------------------------------------------------- |
  3039.        | | *                                              | |
  3040.        | | ---------------------------------------------- | |
  3041.        | | | 1                                          | | |
  3042.        | | ---------------------------------------------- | |
  3043.        | | ---------------------------------------------- | |
  3044.        | | | 2                                          | | |
  3045.        | | ---------------------------------------------- | |
  3046.        | -------------------------------------------------- |
  3047.        | -------------------------------------------------- |
  3048.        | | 3                                              | |
  3049.        | -------------------------------------------------- |
  3050.        ------------------------------------------------------
  3051.  
  3052.        This format can not show all the nodes in a 5D program.
  3053.        Grasp the edge of a box with the mouse and move it outwards
  3054.        to "zoom in" on that box, or move it inwards to move up the
  3055.        tree.
  3056.  
  3057.        There are two or more tree windows. You may "cut" or "copy"
  3058.        a tree in one window, and copy it to the other one.
  3059.  
  3060.        If a node has off-screen parents or children, its box is
  3061.        drawn differently, alerting you that there is more.
  3062.  
  3063.        7.2  _N_o_d_e__W_i_n_d_o_w
  3064.  
  3065.        When you select a tree node, you may view that node in full
  3066.        in the node window. This window shows all the keywords
  3067.        interpreted appropriately, and all extant properties.
  3068.  
  3069.        7.3  _T_r_e_e__t_y_p_e_s
  3070.  
  3071.        The 5D text format includes the ability to include files.
  3072.        These include commands should be preprocessed before a tree
  3073.        is downloaded, unless the deck possesses access to a
  3074.        universal file name space.
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.                                   - 31 -
  3089.  
  3090.  
  3091.  
  3092.        TF allows you to specify that the contents of a sub-tree
  3093.        adhere to a given subset of 5D node types, via the template
  3094.        mechanism.  TF saves this non-program information as
  3095.        comments in the source, via text comments starting with
  3096.        "_F_o_r_m_a_t:", to remember in a later session how you wish to
  3097.        view your programs.  It can translate other formats into 5D
  3098.        format, allow you to edit the resulting tree, and save it
  3099.        out in any format.  Also, if configured correctly, TF can
  3100.        invoke an appropriate editor.  You would probably wish to
  3101.        use a real 3D modeller to edit a 3D model instead of editing
  3102.        the 5D tree; ordinary differential equations are much more
  3103.        tractable in the form
  3104.  
  3105.                  xxxx'''' ==== xxxx ++++ yyyy
  3106.                  yyyy'''' ==== ----xxxx ++++ yyyy
  3107.        than as the equivalent 5D format.
  3108.  
  3109.        7.4  _C_l_a_s_s__L_a_t_t_i_c_e__B_r_o_w_s_e_r
  3110.  
  3111.        You may browse the class inheritance lattice via the class
  3112.        browser window.  Of course, you may not edit the class
  3113.        inheritance lattice directly.  The lattice is displayed
  3114.        using Venn diagram boxes.
  3115.  
  3116.        A series of class definitions, where abstract superclasses
  3117.        and type-bearing classes are named appropriately:
  3118.  
  3119.        (class  ID=abstract1)
  3120.  
  3121.        (class  ID=abstract2)
  3122.  
  3123.        (class  ID=atype
  3124.            super=abstract1
  3125.            super=abstract2
  3126.        )
  3127.        would display in the class lattice browser:
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.  
  3136.  
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.                                   - 32 -
  3155.  
  3156.  
  3157.  
  3158.        ------------------------------------------------------
  3159.        | ------------------------------                     |
  3160.        | | abstract1                  |                     |
  3161.        | |                            |                     |
  3162.        | |                            |                     |
  3163.        | |                  ------------------------------- |
  3164.        | |                  |         |                   | |
  3165.        | |                  |  atype  |                   | |
  3166.        | |                  |         |                   | |
  3167.        | -------------------|----------                   | |
  3168.        |                    |                             | |
  3169.        |                    |                             | |
  3170.        |                    |                   abstract2 | |
  3171.        |                    ------------------------------- |
  3172.        ------------------------------------------------------
  3173.  
  3174.  
  3175.        The browser window cannot display the entire class lattice.
  3176.        It does not attempt to show all possible intersections, nor
  3177.        even all the intersections of a particular superclass.  If a
  3178.        class has any unseen intersections, the border of its box is
  3179.        different (monochrome) or its name is in a different color.
  3180.        Classes with no on-screen children are not drawn with their
  3181.        own box, but if they have children they are underlined or
  3182.        drawn in color.  This is simply to avoid screen clutter, or
  3183.        "non-data ink".  [ Envisioning Information, Edward Tufte. ]
  3184.  
  3185.        To look at all intersections of a superclass, select that
  3186.        class.  To select a subset of the intersections of one or
  3187.        more classes, mouse-down in one intersection box and drag
  3188.        the mouse through all intersections in which you are
  3189.        interested.  Since this is a Venn diagram, neighboring boxes
  3190.        form a simplified Boolean expression.
  3191.  
  3192.        7.5  _O_p_e_r_a_t_o_r_s
  3193.  
  3194.        The operator menu gives a list of defined operators.  It can
  3195.        give a list of all operators, operators unique to one class,
  3196.        or multiply defined operators.
  3197.  
  3198.        7.6  _A_d_d_r_e_s_s__n_o_d_e_s
  3199.  
  3200.        Address nodes are marked, but automatically are drawn in the
  3201.        type of the node they point to.
  3202.  
  3203.                                   - 50 -
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.  
  3243.  
  3244.  
  3245.  
  3246.  
  3247.  
  3248.  
  3249.  
  3250.  
  3251.  
  3252.  
  3253.  
  3254.  
  3255.  
  3256.  
  3257.  
  3258.  
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.                                   - 51 -
  3270.  
  3271.  
  3272.  
  3273.        9.  _5_D__L_i_b_r_a_r_y
  3274.  
  3275.        Every deck includes a large library of pre-defined trees
  3276.        which do a variety of basic operations:  2D bitmaps, text,
  3277.        sample objects, colors, & textures, etc.  The library trees
  3278.        are assigned a pre-defined block of IDs.  5D program and
  3279.        tree authors may always assume these classes are available,
  3280.        as well as the primitive class library.  The following trees
  3281.        are from the core tree library, and are a sample of simple
  3282.        5D tree composition.
  3283.  
  3284.        9.0.1  _F_l_o_a_t_i_n_g__P_i_x_m_a_p_
  3285.        The Floating Pixmap is a 2D pixmap which should not be sub-
  3286.        or super-sampled, and instead should only be seen at a fixed
  3287.        size and place.  It sets its 2D bounding box to force this
  3288.        to occur.  This might be used for system status messages.
  3289.  
  3290.  
  3291.        ( class
  3292.            ID='Floating Pixmap'
  3293.            super=Painted
  3294.            ( method
  3295.                name=Float
  3296.                ( template
  3297.                    (ID=Pix type=Pixmap)
  3298.                    (ID=Frame type=Drawable)
  3299.                    (ID=Place type=Box)
  3300.                )
  3301.                ( rewrite
  3302.                    type=Void
  3303.                    / Set screen box to force placement on screen
  3304.                    ( property
  3305.                        name=screenbox
  3306.                        value=Place
  3307.                    )
  3308.                    / If the sizes of the pixmap and the frame are
  3309.                    / mis-matched, an exception will be raised,
  3310.                    / so don't bother checking them here.
  3311.                    Apply(Pix, Frame)
  3312.                )
  3313.            )
  3314.        )
  3315.  
  3316.        Notes:
  3317.  
  3318.           +o Obviously, the Floating Pixmap would only be invoked
  3319.             during a screen refresh.  As a defined tree, the
  3320.             Floating Pixmap inherits the evaluation frequency
  3321.             property at invocation time.  Setting the evaluation
  3322.             frequency would make no sense.
  3323.  
  3324.  
  3325.  
  3326.  
  3327.  
  3328.  
  3329.  
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.                                   - 52 -
  3336.  
  3337.  
  3338.  
  3339.           +o The core library is assumed to be pre-loaded in the
  3340.             deck, and its members are referred to by standardized
  3341.             code numbers.  However, since Floating Pixmaps can be
  3342.             described in 5D, they belong in the core library, not
  3343.             the language specification.
  3344.  
  3345.           +o A fixed-size pixmap will be legible anywhere on the
  3346.             screen.  Since its placement is a 2D graphics decision,
  3347.             that is left up to the invoker.
  3348.  
  3349.        9.0.2  _S_t_e_r_e_o__F_l_o_a_t_i_n_g__P_i_x_m_a_p
  3350.        The Stereo Floating Pixmap object uses two instances of the
  3351.        Floating Pixmap object to create a stereo image in a fixed
  3352.        size and place on the screen.  Random sub- or super-sampling
  3353.        the left and right frames of a stereo image would give your
  3354.        visual system severe grief, so the Floating Pixmap library
  3355.        routine is the appropriate choice.  The stereo input pixmaps
  3356.        may be produced with a ray-tracer or stereo video pairs.
  3357.  
  3358.  
  3359.        ( class
  3360.            ID='Stereo Floating Pixmap'
  3361.            super='Floating Pixmap'
  3362.  
  3363.            ( method
  3364.                name=Float
  3365.                ( template
  3366.                (ID=PixLeft type=Pixmap)
  3367.                (ID=PixRight type=Pixmap)
  3368.                (ID=Frame type=Drawable)
  3369.                (ID=Place type=Box)
  3370.                )
  3371.                ( rewrite
  3372.                    type=Void
  3373.                / Set screen box, which forces placement on screen
  3374.                ( property
  3375.                    name=screenbox
  3376.                    value=Place
  3377.                )
  3378.                / Type of cond is VOID, so can't do cond(left, pix, pix)
  3379.                cond(LeftEye,
  3380.                    Apply(PixLeft, Frame),
  3381.                    Apply(PixRight, Frame))
  3382.                )
  3383.            )
  3384.        )
  3385.  
  3386.        Notes:
  3387.  
  3388.           +o The Stereo Floating Pixmap needs two input bitmaps, and
  3389.             the size and placement to use for the maps.  It uses
  3390.  
  3391.  
  3392.  
  3393.  
  3394.  
  3395.  
  3396.  
  3397.  
  3398.  
  3399.  
  3400.  
  3401.                                   - 53 -
  3402.  
  3403.  
  3404.  
  3405.             the intrinsic boolean variable left_eye to decide
  3406.             whether to invoke the Floating Pixmap object on the
  3407.             left or right eye image.  Again, the object should only
  3408.             be invoked during a retrace event.
  3409.  
  3410.           +o With video-in-a-window, you could do this with live
  3411.             stereo pairs.
  3412.  
  3413.        9.0.3  _S_o_u_n_d__s_a_m_p_l_e__a_t_t_a_c_h_e_d__t_o__o_b_j_e_c_t
  3414.        This class definition plays a continuously cycled sound
  3415.        sample or synthesizer patch.  It adjusts the volume to your
  3416.        distance from it.  This is usually part of a larger object.
  3417.  
  3418.  
  3419.        ( class
  3420.            ID='Positioned Sound'
  3421.            super=SoundChannel
  3422.  
  3423.            ( property
  3424.                name=Volume
  3425.                (
  3426.                    type=Number
  3427.                    distance((property name=Position type=Point),
  3428.                        EyePoint type=Point)
  3429.                )
  3430.            )
  3431.  
  3432.            ( property
  3433.                name=execute
  3434.                value=True
  3435.            )
  3436.  
  3437.        )
  3438.  
  3439.        Notes:
  3440.  
  3441.           +o The actual format of sound samples and instrument
  3442.             definitions is very deck-dependent.  Low-end PC sound
  3443.             boards have a bunch of oscillators.  They allow you to
  3444.             set a bunch of registers for instrument X out of 10,
  3445.             and then leave it alone.  Higher-end gear requires
  3446.             generating sound samples on the fly and feeding them to
  3447.             DMA channels.  The very desirable ability to have
  3448.             high-level definitions of several simultaneous sound
  3449.             channels making iconic sounds (a FWOOOSH when you grab
  3450.             something, a TINK when you hit something metal) is thus
  3451.             much easier on PC's than workstations.  On the other
  3452.             hand, we need to go to more sophisticated hardware to
  3453.             get stereo or 3D sound placement.  There has been work
  3454.             on doing 2D placement with Midi.  [Computer Music
  3455.             Journal, Feb. 1991, pp. 59] Midi I/O is available for
  3456.  
  3457.  
  3458.  
  3459.  
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.                                   - 54 -
  3468.  
  3469.  
  3470.  
  3471.             all desktop PC's; this is an obvious direction for
  3472.             research.
  3473.  
  3474.        9.0.4  _F_l_i_p_-_F_l_o_p
  3475.        The flip-flop uses feedback to create a simple 1-bit memory
  3476.        of past inputs.
  3477.  
  3478.        9.0.5  _S_o_f_t_w_a_r_e__P_h_a_s_e_-_L_o_c_k_e_d__L_o_o_p
  3479.        The phase-locked loop is a key circuit used in interfacing
  3480.        analog and digital circuitry.  The Synthesis operating
  3481.        system [ref: Columbia University Technical Report] uses a
  3482.        software implementation of a PLL as its scheduler.  Software
  3483.        PLLs provide a simple, fast system that responds to external
  3484.        rhythms.  A software PLL can interface real-time output to a
  3485.        user's work rhythm, and gives a powerful tool for making the
  3486.        user interface controlled by the user's time sense.
  3487.  
  3488.        It should be possible to interface the MIDI ports with the
  3489.        software PLL to do interesting drum machine stuff.
  3490.  
  3491.        9.0.6  _S_a_m_p_l_e__&__H_o_l_d
  3492.        Sample and hold an input value.  Whenever the input switch
  3493.        is true, sample the value.  Whenever the input value
  3494.        changes, sample the value.  Output the held value on demand.
  3495.  
  3496.  
  3497.                  ( class
  3498.                      ID='Sample and Hold'
  3499.                      super=Number
  3500.                      super=Boolean
  3501.                      ( data
  3502.                          / secret data sampled & held
  3503.                          ID=$Sample
  3504.                          type=Number
  3505.                      )
  3506.  
  3507.  
  3508.  
  3509.  
  3510.  
  3511.  
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.                                   - 55 -
  3534.  
  3535.  
  3536.  
  3537.                      ( method
  3538.                          / grab data when boolean is true,
  3539.                          / and when number changes while boolean is true
  3540.                          ( template
  3541.                              name=Sample
  3542.                              type=Number
  3543.                              ( name=switch type=Boolean )
  3544.                              ( name=input type=Number)
  3545.                          )
  3546.                          ( rewrite
  3547.                              (cond
  3548.                                  (and
  3549.                                      (switch)
  3550.                                      (or
  3551.                                          (inputChange(switch))
  3552.                                          (inputChange(value))
  3553.                                      )
  3554.                                  )
  3555.                                  (set($Sample, input))
  3556.                                  ()  / else do nothing
  3557.                              )
  3558.                          )
  3559.                      )
  3560.                      ( method
  3561.                          ( template
  3562.                              name=Value
  3563.                          )
  3564.                          ( rewrite
  3565.                              type=Number
  3566.                              set(output, $Sample)
  3567.                          )
  3568.                      )
  3569.                  )
  3570.  
  3571.        The inputChange boolean operation is extremely useful for
  3572.        asynchronous operations such as Sample&Hold.  This class
  3573.        does not operate continuously, of course, but instead is
  3574.        driven by its inherited clock.
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.                                   - 56 -
  3600.  
  3601.  
  3602.  
  3603.        10.  _5_D__S_a_m_p_l_e__P_r_o_g_r_a_m_s
  3604.  
  3605.        The following program is in severely abridged pidgin 5D for
  3606.        clarity.  It dates back to before the addition of objects to
  3607.        5D, but does give the flavor of 5D programming.
  3608.  
  3609.        10.1  _S_o_u_n_d__m_i_x_e_r
  3610.  
  3611.        This is a sample 5D program which implements a simple
  3612.        digital sound mixer.  It allows the user to record and play
  3613.        back 2 sound samples.
  3614.  
  3615.        top of world            / visible universe
  3616.        (
  3617.            / built-in boolean switch1          record channel 1
  3618.            / built-in boolean switch2          record channel 2
  3619.            / built-in boolean switch3          playback channel 1
  3620.            / built-in boolean switch4          playback channel 2
  3621.            / built-in boolean switch5          playback both channels
  3622.            call [
  3623.                property: evaluate when input changes
  3624.                evaluate [
  3625.                    property: evaluate never
  3626.                    dataset sample1 [
  3627.                        property: sound sample, 10 seconds long.
  3628.                    ]
  3629.                    dataset sample2 [
  3630.                        property: sound sample, 10 seconds long.
  3631.                    ]
  3632.                ]
  3633.                evalute [
  3634.                    property: evaluate in order         / concurrency control
  3635.                    conditional [
  3636.                        switch1
  3637.                        assign [                        / record sample 1
  3638.                            sample1
  3639.                            microphone
  3640.                        ]
  3641.                        null
  3642.                    ]
  3643.                    conditional [
  3644.                        switch2
  3645.                        assign [                        / play sample 1
  3646.                            sound channel 1
  3647.                            sample1
  3648.                        ]
  3649.                        null
  3650.                    ]
  3651.                    conditional [
  3652.                         switch3
  3653.                         assign [                       / record sample 2
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.  
  3664.  
  3665.                                   - 57 -
  3666.  
  3667.  
  3668.  
  3669.                             sample2
  3670.                             microphone
  3671.                         ]
  3672.                        null
  3673.                    ]
  3674.                    conditional [
  3675.                    switch4
  3676.                    assign [                            / play sample 2
  3677.                                sound channel 2
  3678.                                sample2
  3679.                            ]
  3680.                        null
  3681.                    ]
  3682.                    conditional [
  3683.                        switch5
  3684.                        evaluate [                      / mix both samples
  3685.                            property: evaluate simultaneously
  3686.                            assign [
  3687.                                sound channel 1
  3688.                                sample1
  3689.                            ]
  3690.                            assign [
  3691.                                sound channel 2
  3692.                                sample2
  3693.                            ]
  3694.                        ]
  3695.                        null                            / empty function
  3696.                    ]
  3697.                ]
  3698.            ]
  3699.        ]
  3700.  
  3701.        This example world has no graphics.  Five switches are used,
  3702.        one for each possible operation.  The property of sequenced
  3703.        evaluation of sub-trees is used to provide concurrency
  3704.        control; only one operation at a time may be used.  A tree
  3705.        which is never evaluated is used as a data holder for the
  3706.        two sound samples.  The following version uses nested
  3707.        conditionals:
  3708.  
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721.  
  3722.  
  3723.  
  3724.  
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730.  
  3731.                                   - 58 -
  3732.  
  3733.  
  3734.  
  3735.        top of world
  3736.        [
  3737.            / built-in boolean switch1;         record channel 1
  3738.            / built-in boolean switch2;         record channel 2
  3739.            / built-in boolean switch3;         playback channel 1
  3740.            / built-in boolean switch4;         playback channel 2
  3741.            / built-in boolean switch5;         playback both channels
  3742.            evaluate all [
  3743.            property: evaluate when input changes
  3744.                evaluate [
  3745.                    property: evaluate never
  3746.                    dataset sample1 [
  3747.                        property: sound sample, 10 seconds long.
  3748.                    ]
  3749.                    dataset sample2 [
  3750.                        property: sound sample, 10 seconds long.
  3751.                    ]
  3752.                ]
  3753.                conditional [
  3754.                    property: evaluate in order/ concurrency control
  3755.                    switch1
  3756.                    assign [                            / record sample 1
  3757.                        sample1
  3758.                        microphone
  3759.                    ]
  3760.                    conditional [
  3761.                        switch2
  3762.                        assign [                        / play sample 1
  3763.                            sound channel 1
  3764.                            sample1
  3765.                        ]
  3766.                        conditional [
  3767.                            switch3
  3768.                            assign [                    / record sample 2
  3769.                                sample2
  3770.                                microphone
  3771.                            ]
  3772.                            conditional [
  3773.                                switch4
  3774.                                assign [                / play sample 2
  3775.                                    sound channel 2
  3776.                                    sample2
  3777.                                ]
  3778.                                conditional [
  3779.                                    switch5
  3780.                                    evaluate [          / mix both samples
  3781.                                        property: evaluate simultaneously
  3782.                                        assign [
  3783.                                            sound channel 1
  3784.                                            sample1
  3785.                                        ]
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.                                   - 59 -
  3798.  
  3799.  
  3800.  
  3801.                                        assign [
  3802.                                            sound channel 2
  3803.                                            sample2
  3804.                                        ]
  3805.                                    ]
  3806.                                    null / empty tree
  3807.                                ]
  3808.                            ]
  3809.                        ]
  3810.                    ]
  3811.                ]
  3812.            ]
  3813.        ]
  3814.  
  3815.        Note that the version with nested conditionals still uses
  3816.        the sequential evaluation property.  Multi-processor systems
  3817.        can evaluate all 3 branches of a conditional expression
  3818.        concurrently, being careful that the false leg of the then-
  3819.        else pair leaves no permanent side effects.
  3820.